1 11 package org.eclipse.pde.internal.build.jarprocessor; 12 13 import java.io.File ; 14 import java.io.IOException ; 15 import java.util.List ; 16 import java.util.Properties ; 17 import org.apache.tools.ant.BuildException; 18 import org.apache.tools.ant.Project; 19 import org.apache.tools.ant.taskdefs.SignJar; 20 import org.eclipse.update.internal.jarprocessor.SignCommandStep; 21 22 public class AntSignCommand extends SignCommandStep { 23 private Project project; 24 private Properties jarSignerArguments; 25 private String antTaskName; 26 27 public AntSignCommand(Properties options, Properties signArguments, Project project, String antTaskName, String command, boolean verbose) { 28 super(options, command, verbose); 29 this.project = project; 30 this.jarSignerArguments = signArguments; 31 this.antTaskName = antTaskName; 32 } 33 34 public File postProcess(File input, File workingDirectory, List containers) { 35 if (command != null && input != null && shouldSign(input, containers)) { 36 execute(input); 37 } 38 return null; 39 } 40 41 private void execute(File input) { 42 try { 43 SignJar jarSigner = new SignJar(); 44 jarSigner.setJar(input); 45 jarSigner.setAlias(jarSignerArguments.getProperty(JarProcessorTask.ALIAS)); 46 jarSigner.setKeystore(jarSignerArguments.getProperty(JarProcessorTask.KEYSTORE)); 47 jarSigner.setStorepass(jarSignerArguments.getProperty(JarProcessorTask.STOREPASS)); 48 jarSigner.setProject(project); 49 jarSigner.setTaskName(antTaskName); 50 jarSigner.execute(); 51 } catch (BuildException e) { 52 if (e.getCause() instanceof IOException ) { 53 throw new BuildException("The jarsigner could not be found. Make sure to run with the build with a JDK.", e); } 55 throw e; 56 } 57 } 58 } 59 | Popular Tags |