KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > build > jarprocessor > AntSignCommand


1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM - Initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.build.jarprocessor;
12
13 import java.io.File JavaDoc;
14 import java.io.IOException JavaDoc;
15 import java.util.List JavaDoc;
16 import java.util.Properties JavaDoc;
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 JavaDoc jarSignerArguments;
25     private String JavaDoc antTaskName;
26
27     public AntSignCommand(Properties JavaDoc options, Properties JavaDoc signArguments, Project project, String JavaDoc antTaskName, String JavaDoc 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 JavaDoc postProcess(File JavaDoc input, File JavaDoc workingDirectory, List JavaDoc containers) {
35         if (command != null && input != null && shouldSign(input, containers)) {
36             execute(input);
37         }
38         return null;
39     }
40
41     private void execute(File JavaDoc 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 JavaDoc) {
53                 throw new BuildException("The jarsigner could not be found. Make sure to run with the build with a JDK.", e); //$NON-NLS-1$
54
}
55             throw e;
56         }
57     }
58 }
59
Popular Tags