1 11 package org.eclipse.pde.internal.build.jarprocessor; 12 13 import java.io.File ; 14 import java.util.Properties ; 15 import org.apache.tools.ant.BuildException; 16 import org.apache.tools.ant.Task; 17 import org.eclipse.update.internal.jarprocessor.Main.Options; 18 19 24 public class JarProcessorTask extends Task { 25 private Options options = new Options(); 26 private Properties signArgs = new Properties (); 27 28 public static final String ALIAS = "alias"; public static final String KEYSTORE = "keystore"; public static final String STOREPASS = "storepass"; public static final String UNSIGN = "unsign"; public static final String SIGN = "sign"; 34 private static final String FAKE_COMMAND = "fake"; 36 public void setAlias(String alias) { 37 signArgs.setProperty(ALIAS, alias); 38 } 39 40 public void setKeystore(String keystore) { 41 signArgs.setProperty(KEYSTORE, keystore); 42 } 43 44 public void setJar(File jar) { 45 options.input = jar; 46 options.outputDir = jar.getParentFile().getAbsolutePath(); 47 } 48 49 public void setStorepass(String storepass) { 50 signArgs.setProperty(STOREPASS, storepass); 51 } 52 53 public void setPack(boolean pack) { 54 options.pack = pack; 55 } 56 57 public void setNormalize(boolean normalize) { 58 options.repack = normalize; 59 } 60 61 public void setUnsign(boolean unsign) { 62 if (unsign) { 63 signArgs.put(UNSIGN, Boolean.TRUE.toString()); 64 options.signCommand = FAKE_COMMAND; 65 } 66 } 67 68 public void setSign(boolean sign) { 69 if (sign) { 70 signArgs.put(SIGN, Boolean.TRUE.toString()); 71 options.signCommand = FAKE_COMMAND; 72 } 73 } 74 75 private void adjustAndValidateConfiguration() { 76 if (options.signCommand != null && options.pack) 78 options.repack = true; 79 80 if (options.signCommand != null && signArgs.getProperty(UNSIGN) == null) { 82 if (signArgs.getProperty(ALIAS) == null) 83 throw new BuildException("Alias must be set"); 85 if (signArgs.getProperty(STOREPASS) == null) 86 throw new BuildException("Storepass must be set"); } 88 } 89 90 public void execute() { 91 options.processAll = true; 92 adjustAndValidateConfiguration(); 93 new AntBasedProcessorExecutor(signArgs, getProject(), getTaskName()).runJarProcessor(options); 94 } 95 96 public void setVerbose(boolean verbose) { 97 options.verbose = verbose; 98 } 99 } 100 | Popular Tags |