diff options
author | Pascal Rapicault | 2010-01-13 17:29:41 +0000 |
---|---|---|
committer | Pascal Rapicault | 2010-01-13 17:29:41 +0000 |
commit | 18189f0d42f7375660762dc6c885cf31683ae562 (patch) | |
tree | 17775d847bed9a33f3c68b74db2df75a2139c0bc /bundles/org.eclipse.equinox.p2.jarprocessor | |
parent | c363f2984a09b73c422e38f4556fd3b23eafe958 (diff) | |
download | rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.tar.gz rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.tar.xz rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.zip |
Merging api branch back to HEADv20100113
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.jarprocessor')
6 files changed, 88 insertions, 94 deletions
diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/PackStep.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/PackStep.java index 9258caf7b..3d519736d 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/PackStep.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/PackStep.java @@ -12,11 +12,7 @@ package org.eclipse.equinox.internal.p2.jarprocessor; import java.io.File; import java.io.IOException; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.Set; +import java.util.*; public class PackStep extends CommandStep { diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java index 9cf22bce9..d6bbc6a36 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java @@ -15,7 +15,6 @@ import java.util.*; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.zip.ZipException; - import org.eclipse.internal.provisional.equinox.p2.jarprocessor.JarProcessor; /** diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/verifier/Verifier.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/verifier/Verifier.java index 8aea9d172..322d77905 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/verifier/Verifier.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/verifier/Verifier.java @@ -96,6 +96,7 @@ public class Verifier extends JarProcessorExecutor { return super.processJar(inputFile); } }; + verifier.setWorkingDirectory(workingDirectory.getAbsolutePath()); for (int i = 0; i < input.length; i++) { File inputFile = new File(input[i]); diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/verifier/VerifyStep.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/verifier/VerifyStep.java index 7e63698b8..f9b19351e 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/verifier/VerifyStep.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/verifier/VerifyStep.java @@ -13,7 +13,6 @@ import java.io.File; import java.io.IOException; import java.util.List; import java.util.Properties; - import org.eclipse.equinox.internal.p2.jarprocessor.CommandStep; import org.eclipse.equinox.internal.p2.jarprocessor.Utils; diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessor.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessor.java index 15811e275..b22bc8e9b 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessor.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessor.java @@ -214,16 +214,17 @@ public class JarProcessor { extracted.setLastModified(entry.getTime()); //recurse - containingInfs.addFirst(inf); String dir = getWorkingDirectory(); - setWorkingDirectory(parentDir.getCanonicalPath()); - File result = processJar(extracted); - - newName = name.substring(0, name.length() - extracted.getName().length()) + result.getName(); - data.put(name, newName); - - setWorkingDirectory(dir); - containingInfs.removeFirst(); + try { + containingInfs.addFirst(inf); + setWorkingDirectory(parentDir.getCanonicalPath()); + File result = processJar(extracted); + newName = name.substring(0, name.length() - extracted.getName().length()) + result.getName(); + data.put(name, newName); + } finally { + setWorkingDirectory(dir); + containingInfs.removeFirst(); + } //delete the extracted item leaving the recursion result if (!name.equals(newName)) @@ -263,92 +264,93 @@ public class JarProcessor { } public File processJar(File input) throws IOException { + File tempDir = null; ++depth; - long lastModified = input.lastModified(); - File workingDir = new File(getWorkingDirectory()); - if (!workingDir.exists()) - workingDir.mkdirs(); - - boolean skip = Utils.shouldSkipJar(input, processAll, verbose); - if (depth == 0 && verbose) { - if (skip) - System.out.println("Skipping " + input.getPath()); //$NON-NLS-1$ - else { - System.out.print("Running "); //$NON-NLS-1$ - for (Iterator iter = steps.iterator(); iter.hasNext();) { - IProcessStep step = (IProcessStep) iter.next(); - System.out.print(step.getStepName() + " "); //$NON-NLS-1$ + try { + long lastModified = input.lastModified(); + File workingDir = new File(getWorkingDirectory()); + if (!workingDir.exists()) + workingDir.mkdirs(); + + boolean skip = Utils.shouldSkipJar(input, processAll, verbose); + if (depth == 0 && verbose) { + if (skip) + System.out.println("Skipping " + input.getPath()); //$NON-NLS-1$ + else { + System.out.print("Running "); //$NON-NLS-1$ + for (Iterator iter = steps.iterator(); iter.hasNext();) { + IProcessStep step = (IProcessStep) iter.next(); + System.out.print(step.getStepName() + " "); //$NON-NLS-1$ + } + System.out.println("on " + input.getPath()); //$NON-NLS-1$ } - System.out.println("on " + input.getPath()); //$NON-NLS-1$ } - } - if (skip) { - //This jar was not marked as conditioned, and we are only processing conditioned jars, so do nothing - --depth; - return input; - } - - //pre - File workingFile = preProcess(input, workingDir); + if (skip) { + //This jar was not marked as conditioned, and we are only processing conditioned jars, so do nothing + return input; + } - //Extract entries from jar and recurse on them - File tempDir = null; - if (depth == 0) { - tempDir = new File(workingDir, "temp." + workingFile.getName()); //$NON-NLS-1$ - } else { - File parent = workingDir.getParentFile(); - tempDir = new File(parent, "temp_" + depth + '_' + workingFile.getName()); //$NON-NLS-1$ - } + //pre + File workingFile = preProcess(input, workingDir); - JarFile jar = new JarFile(workingFile, false); - Map replacements = new HashMap(); - Properties inf = Utils.getEclipseInf(workingFile, verbose); - extractEntries(jar, tempDir, replacements, inf); - - if (inf != null) - adjustInf(workingFile, inf); - - //Recreate the jar with replacements. - //TODO: This is not strictly necessary if we didn't change the inf file and didn't change any content - File tempJar = null; - tempJar = new File(tempDir, workingFile.getName()); - File parent = tempJar.getParentFile(); - if (!parent.exists()) - parent.mkdirs(); - JarOutputStream jarOut = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(tempJar))); - recreateJar(jar, jarOut, replacements, tempDir, inf); - - jar.close(); - if (tempJar != null) { - if (!workingFile.equals(input)) { - workingFile.delete(); + //Extract entries from jar and recurse on them + if (depth == 0) { + tempDir = new File(workingDir, "temp." + workingFile.getName()); //$NON-NLS-1$ + } else { + File parent = workingDir.getParentFile(); + tempDir = new File(parent, "temp_" + depth + '_' + workingFile.getName()); //$NON-NLS-1$ } - workingFile = tempJar; - } - //post - File result = postProcess(workingFile, workingDir); + JarFile jar = new JarFile(workingFile, false); + Map replacements = new HashMap(); + Properties inf = Utils.getEclipseInf(workingFile, verbose); + extractEntries(jar, tempDir, replacements, inf); + + if (inf != null) + adjustInf(workingFile, inf); + + //Recreate the jar with replacements. + //TODO: This is not strictly necessary if we didn't change the inf file and didn't change any content + File tempJar = null; + tempJar = new File(tempDir, workingFile.getName()); + File parent = tempJar.getParentFile(); + if (!parent.exists()) + parent.mkdirs(); + JarOutputStream jarOut = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(tempJar))); + recreateJar(jar, jarOut, replacements, tempDir, inf); - //have to normalize after the post steps - normalize(result, workingDir); + jar.close(); + if (tempJar != null) { + if (!workingFile.equals(input)) { + workingFile.delete(); + } + workingFile = tempJar; + } - if (!result.equals(workingFile) && !workingFile.equals(input)) - workingFile.delete(); - if (!result.getParentFile().equals(workingDir)) { - File finalFile = new File(workingDir, result.getName()); - if (finalFile.exists()) - finalFile.delete(); - result.renameTo(finalFile); - result = finalFile; - } + //post + File result = postProcess(workingFile, workingDir); - if (tempDir.exists()) - Utils.clear(tempDir); + //have to normalize after the post steps + normalize(result, workingDir); - result.setLastModified(lastModified); - --depth; - return result; + if (!result.equals(workingFile) && !workingFile.equals(input)) + workingFile.delete(); + if (!result.getParentFile().equals(workingDir)) { + File finalFile = new File(workingDir, result.getName()); + if (finalFile.exists()) + finalFile.delete(); + result.renameTo(finalFile); + result = finalFile; + } + + result.setLastModified(lastModified); + return result; + } finally { + --depth; + if (tempDir != null && tempDir.exists()) + Utils.clear(tempDir); + } } private void normalize(File input, File directory) { 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 8f6993f00..c8cfbfad1 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 @@ -13,10 +13,7 @@ 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.*; import org.apache.tools.ant.types.FileSet; import org.eclipse.internal.provisional.equinox.p2.jarprocessor.JarProcessorExecutor.Options; |