Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2009-03-03 18:45:09 +0000
committerAndrew Niefer2009-03-03 18:45:09 +0000
commita1483010906ddb6e5b19191fb408165611729838 (patch)
tree805042e16853c24dd22864d66c04b38e6059a8c0 /bundles
parent3169ccb2892f30a4cb833436d959ebd52f6eb71b (diff)
downloadrt.equinox.p2-a1483010906ddb6e5b19191fb408165611729838.tar.gz
rt.equinox.p2-a1483010906ddb6e5b19191fb408165611729838.tar.xz
rt.equinox.p2-a1483010906ddb6e5b19191fb408165611729838.zip
bug 265726 - use new p2.process.artifacts for signing
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessorExecutor.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/AntBasedProcessorExecutor.java44
-rw-r--r--bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/JarProcessorTask.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java56
4 files changed, 132 insertions, 23 deletions
diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessorExecutor.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessorExecutor.java
index 6fed1b269..8d64a4ce1 100644
--- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessorExecutor.java
+++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessorExecutor.java
@@ -87,7 +87,8 @@ public class JarProcessorExecutor {
}
try {
- process(options.input, options.unpack ? Utils.PACK_GZ_FILTER : Utils.JAR_FILTER, options.verbose, processor, packProcessor);
+ FileFilter filter = createFileFilter(options);
+ process(options.input, filter, options.verbose, processor, packProcessor);
} catch (FileNotFoundException e) {
if (options.verbose)
e.printStackTrace();
@@ -95,6 +96,10 @@ public class JarProcessorExecutor {
}
}
+ protected FileFilter createFileFilter(Options options) {
+ return options.unpack ? Utils.PACK_GZ_FILTER : Utils.JAR_FILTER;
+ }
+
protected void process(File input, FileFilter filter, boolean verbose, JarProcessor processor, JarProcessor packProcessor) throws FileNotFoundException {
if (!input.exists())
throw new FileNotFoundException();
@@ -108,14 +113,7 @@ public class JarProcessorExecutor {
return;
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
- String dir = processor.getWorkingDirectory();
- processor.setWorkingDirectory(dir + "/" + files[i].getName()); //$NON-NLS-1$
- if (packProcessor != null)
- packProcessor.setWorkingDirectory(dir + "/" + files[i].getName()); //$NON-NLS-1$
- process(files[i], filter, verbose, processor, packProcessor);
- processor.setWorkingDirectory(dir);
- if (packProcessor != null)
- packProcessor.setWorkingDirectory(dir);
+ processDirectory(files[i], filter, verbose, processor, packProcessor);
} else if (filter.accept(files[i])) {
try {
File result = processor.processJar(files[i]);
@@ -130,6 +128,19 @@ public class JarProcessorExecutor {
}
}
+ protected void processDirectory(File input, FileFilter filter, boolean verbose, JarProcessor processor, JarProcessor packProcessor) throws FileNotFoundException{
+ if (!input.isDirectory())
+ return;
+ String dir = processor.getWorkingDirectory();
+ processor.setWorkingDirectory(dir + "/" + input.getName()); //$NON-NLS-1$
+ if (packProcessor != null)
+ packProcessor.setWorkingDirectory(dir + "/" + input.getName()); //$NON-NLS-1$
+ process(input, filter, verbose, processor, packProcessor);
+ processor.setWorkingDirectory(dir);
+ if (packProcessor != null)
+ packProcessor.setWorkingDirectory(dir);
+ }
+
public void addPackUnpackStep(JarProcessor processor, Properties properties, JarProcessorExecutor.Options options) {
processor.addProcessStep(new PackUnpackStep(properties, options.verbose));
}
diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/AntBasedProcessorExecutor.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/AntBasedProcessorExecutor.java
index 62e995ef5..bb1fbf9df 100644
--- a/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/AntBasedProcessorExecutor.java
+++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/AntBasedProcessorExecutor.java
@@ -10,7 +10,13 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.jarprocessor.ant;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileNotFoundException;
+import java.util.HashSet;
+import java.util.List;
import java.util.Properties;
+
import org.apache.tools.ant.Project;
import org.eclipse.equinox.internal.p2.jarprocessor.unsigner.UnsignCommand;
import org.eclipse.internal.provisional.equinox.p2.jarprocessor.JarProcessor;
@@ -20,17 +26,53 @@ public class AntBasedProcessorExecutor extends JarProcessorExecutor {
private final Project project;
private final Properties signArguments;
private final String antTaskName;
-
+ private List inputFiles;
+ private HashSet filterSet = null;
+ private FileFilter baseFilter = null;
+
public AntBasedProcessorExecutor(Properties signArguments, Project project, String antTaskName) {
this.signArguments = signArguments;
this.project = project;
this.antTaskName = antTaskName;
}
+ protected FileFilter createFileFilter(Options options) {
+ baseFilter = super.createFileFilter(options);
+ if (inputFiles == null || inputFiles.size() == 0)
+ return baseFilter;
+
+ filterSet = new HashSet();
+ filterSet.addAll(inputFiles);
+ return new FileFilter() {
+ public boolean accept(File pathname) {
+ return getFilterSet().contains(pathname);
+ }
+ };
+ }
+
+ protected HashSet getFilterSet() {
+ return filterSet;
+ }
+
+ protected void processDirectory(File input, FileFilter filter, boolean verbose, JarProcessor processor, JarProcessor packProcessor) throws FileNotFoundException{
+ if (filterSet != null && filterSet.contains(input)){
+ File [] files = input.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isDirectory() || baseFilter.accept(files[i]))
+ filterSet.add(files[i]);
+ }
+ }
+ super.processDirectory(input, filter, verbose, processor, packProcessor);
+ }
+
public void addSignStep(JarProcessor processor, Properties properties, Options options) {
if (signArguments.get(JarProcessorTask.UNSIGN) != null)
processor.addProcessStep(new UnsignCommand(properties, options.signCommand, options.verbose));
if (signArguments.get(JarProcessorTask.SIGN) != null)
processor.addProcessStep(new AntSignCommand(properties, signArguments, project, antTaskName, options.signCommand, options.verbose));
}
+
+ public void setInputFiles(List inputFiles) {
+ this.inputFiles = inputFiles;
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/JarProcessorTask.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/JarProcessorTask.java
index 9989bcac9..8f6993f00 100644
--- a/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/JarProcessorTask.java
+++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/JarProcessorTask.java
@@ -11,9 +11,13 @@
package org.eclipse.equinox.internal.p2.jarprocessor.ant;
import java.io.File;
+import java.util.ArrayList;
import java.util.Properties;
+
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileSet;
import org.eclipse.internal.provisional.equinox.p2.jarprocessor.JarProcessorExecutor.Options;
/**
@@ -24,6 +28,7 @@ import org.eclipse.internal.provisional.equinox.p2.jarprocessor.JarProcessorExec
public class JarProcessorTask extends Task {
private final Options options = new Options();
private final Properties signArgs = new Properties();
+ private final ArrayList inputFiles = new ArrayList();
public static final String ALIAS = "alias"; //$NON-NLS-1$
public static final String KEYSTORE = "keystore"; //$NON-NLS-1$
@@ -101,10 +106,29 @@ public class JarProcessorTask extends Task {
public void execute() {
options.processAll = true;
adjustAndValidateConfiguration();
- new AntBasedProcessorExecutor(signArgs, getProject(), getTaskName()).runJarProcessor(options);
+ AntBasedProcessorExecutor executor = new AntBasedProcessorExecutor(signArgs, getProject(), getTaskName());
+ if (inputFiles.size() > 0)
+ executor.setInputFiles(inputFiles);
+ executor.runJarProcessor(options);
}
public void setVerbose(boolean verbose) {
options.verbose = verbose;
}
+
+ public void addInputFile(File file) {
+ inputFiles.add(file);
+ }
+
+ public void addConfiguredFile(FileSet fileset) {
+ DirectoryScanner scanner = fileset.getDirectoryScanner(getProject());
+ String [] included = scanner.getIncludedFiles();
+ for (int i = 0; i < included.length; i++) {
+ addInputFile(new File(scanner.getBasedir(), included[i]));
+ }
+ included = scanner.getIncludedDirectories();
+ for (int i = 0; i < included.length; i++) {
+ addInputFile(new File(scanner.getBasedir(), included[i]));
+ }
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java
index 302a15365..9415092c5 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java
@@ -59,6 +59,7 @@ public class ProcessRepoTask extends Task {
private boolean pack = false;
private boolean repack = false;
private SigningOptions signing = null;
+ private JarProcessorTask jarProcessor = null;
public void execute() throws BuildException {
File file = URIUtil.toFile(repository);
@@ -66,22 +67,23 @@ public class ProcessRepoTask extends Task {
throw new BuildException("Repository must be local: " + repository.toString()); //$NON-NLS-1$
}
if (pack | repack | signing != null) {
- JarProcessorTask task = new JarProcessorTask();
+ if (jarProcessor == null)
+ jarProcessor = new JarProcessorTask();
if (signing != null) {
- task.setAlias(signing.alias);
- task.setKeypass(signing.keypass);
- task.setKeystore(signing.keystore);
- task.setStorepass(signing.storepass);
- task.setUnsign(signing.unsign);
+ jarProcessor.setAlias(signing.alias);
+ jarProcessor.setKeypass(signing.keypass);
+ jarProcessor.setKeystore(signing.keystore);
+ jarProcessor.setStorepass(signing.storepass);
+ jarProcessor.setUnsign(signing.unsign);
if (signing.alias != null && signing.alias.length() > 0 && !signing.alias.startsWith("${")) //$NON-NLS-1$
- task.setSign(true);
+ jarProcessor.setSign(true);
}
- task.setPack(pack);
- task.setNormalize(repack);
- task.setInputFolder(new File(repository));
- task.setProject(getProject());
- task.execute();
+ jarProcessor.setPack(pack);
+ jarProcessor.setNormalize(repack);
+ jarProcessor.setInputFolder(new File(repository));
+ jarProcessor.setProject(getProject());
+ jarProcessor.execute();
}
recreateRepository();
@@ -126,4 +128,34 @@ public class ProcessRepoTask extends Task {
public void addConfiguredSign(SigningOptions options) {
this.signing = options;
}
+
+ public void addConfiguredPlugin(IUDescription iu) {
+ if (jarProcessor == null)
+ jarProcessor = new JarProcessorTask();
+
+ String path = "plugins/" + iu.getId() + '_' + iu.getVersion(); //$NON-NLS-1$
+ File repo = new File(repository);
+ File plugin = new File(repo, path);
+ if (!plugin.exists())
+ plugin = new File(repo, path + ".jar"); //$NON-NLS-1$
+
+ if (plugin.exists()) {
+ jarProcessor.addInputFile(plugin);
+ }
+ }
+
+ public void addConfiguredFeature(IUDescription iu) {
+ if (jarProcessor == null)
+ jarProcessor = new JarProcessorTask();
+
+ String path = "features/" + iu.getId() + '_' + iu.getVersion(); //$NON-NLS-1$
+ File repo = new File(repository);
+ File feature = new File(repo, path);
+ if (!feature.exists())
+ feature = new File(repo, path + ".jar"); //$NON-NLS-1$
+
+ if (feature.exists()) {
+ jarProcessor.addInputFile(feature);
+ }
+ }
}

Back to the top