Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 47083 Details for
Bug 146066
JarProcessor support for explicit packaging decision
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
updated patch
146066.txt (text/plain), 18.12 KB, created by
Andrew Niefer
on 2006-07-31 14:25:47 EDT
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Andrew Niefer
Created:
2006-07-31 14:25:47 EDT
Size:
18.12 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.update.core >Index: src/org/eclipse/update/internal/jarprocessor/IProcessStep.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/IProcessStep.java,v >retrieving revision 1.2 >diff -u -r1.2 IProcessStep.java >--- src/org/eclipse/update/internal/jarprocessor/IProcessStep.java 21 Apr 2006 18:54:55 -0000 1.2 >+++ src/org/eclipse/update/internal/jarprocessor/IProcessStep.java 31 Jul 2006 18:25:05 -0000 >@@ -11,9 +11,10 @@ > package org.eclipse.update.internal.jarprocessor; > > import java.io.File; >+import java.util.Properties; > > /** >- * @author aniefer >+ * @author aniefer@ca.ibm.com > * > */ > public interface IProcessStep { >@@ -50,4 +51,11 @@ > * @return > */ > public String getStepName(); >+ >+ /** >+ * Adjust any properties in the eclipse.inf as appropriate for this step >+ * @param input >+ * @param inf >+ */ >+ public void adjustInf(File input, Properties inf); > } >Index: src/org/eclipse/update/internal/jarprocessor/PackUnpackStep.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/PackUnpackStep.java,v >retrieving revision 1.2 >diff -u -r1.2 PackUnpackStep.java >--- src/org/eclipse/update/internal/jarprocessor/PackUnpackStep.java 21 Apr 2006 18:54:55 -0000 1.2 >+++ src/org/eclipse/update/internal/jarprocessor/PackUnpackStep.java 31 Jul 2006 18:25:05 -0000 >@@ -16,7 +16,7 @@ > import java.util.Set; > > /** >- * @author aniefer >+ * @author aniefer@ca.ibm.com > * > */ > public class PackUnpackStep extends PackStep { >@@ -44,9 +44,15 @@ > */ > public File postProcess(File input, File workingDirectory) { > if (canPack() && packCommand != null) { >+ Properties inf = Utils.getEclipseInf(input); >+ if (inf != null && inf.containsKey(Utils.MARK_EXCLUDE_PACK) && Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_PACK)).booleanValue()) { >+ if (verbose) >+ System.out.println("Excluding " + input.getName() + " from " + getStepName()); //$NON-NLS-1$ //$NON-NLS-2$ >+ return null; >+ } > File tempFile = new File(workingDirectory, "temp_" + input.getName()); //$NON-NLS-1$ > try { >- String[] tmp = getCommand(input, tempFile); >+ String[] tmp = getCommand(input, tempFile, inf); > String[] cmd = new String[tmp.length + 1]; > cmd[0] = tmp[0]; > cmd[1] = "-r"; //$NON-NLS-1$ >Index: src/org/eclipse/update/internal/jarprocessor/ZipProcessor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/ZipProcessor.java,v >retrieving revision 1.3 >diff -u -r1.3 ZipProcessor.java >--- src/org/eclipse/update/internal/jarprocessor/ZipProcessor.java 4 May 2006 20:12:44 -0000 1.3 >+++ src/org/eclipse/update/internal/jarprocessor/ZipProcessor.java 31 Jul 2006 18:25:05 -0000 >@@ -15,7 +15,7 @@ > import java.util.zip.*; > > /** >- * @author aniefer >+ * @author aniefer@ca.ibm.com > * > */ > public class ZipProcessor { >@@ -116,7 +116,7 @@ > FileOutputStream extracted = new FileOutputStream(extractedFile); > Utils.transferStreams(entryStream, extracted, true); > >- boolean skip = !processAll && Utils.isUnmarkedJar(extractedFile); >+ boolean skip = Utils.shouldSkipJar(extractedFile, processAll, verbose); > if (skip) { > //skipping this file > entryStream = new FileInputStream(extractedFile); >Index: src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java,v >retrieving revision 1.3 >diff -u -r1.3 SignCommandStep.java >--- src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java 21 Apr 2006 18:54:55 -0000 1.3 >+++ src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java 31 Jul 2006 18:25:05 -0000 >@@ -15,7 +15,7 @@ > import java.util.jar.*; > > /** >- * @author aniefer >+ * @author aniefer@ca.ibm.com > * > */ > public class SignCommandStep extends CommandStep { >@@ -52,6 +52,12 @@ > */ > public File postProcess(File input, File workingDirectory) { > if (command != null) { >+ Properties inf = Utils.getEclipseInf(input); >+ if (inf != null && inf.containsKey(Utils.MARK_EXCLUDE_SIGN) && Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_SIGN)).booleanValue()) { >+ if(verbose) >+ System.out.println("Excluding " + input.getName() + " from signing."); //$NON-NLS-1$ //$NON-NLS-2$ >+ return null; >+ } > try { > String[] cmd = new String[] {command, input.getCanonicalPath()}; > int result = execute(cmd, verbose); >Index: src/org/eclipse/update/internal/jarprocessor/Utils.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/Utils.java,v >retrieving revision 1.4 >diff -u -r1.4 Utils.java >--- src/org/eclipse/update/internal/jarprocessor/Utils.java 4 May 2006 20:12:44 -0000 1.4 >+++ src/org/eclipse/update/internal/jarprocessor/Utils.java 31 Jul 2006 18:25:05 -0000 >@@ -15,12 +15,20 @@ > import java.util.jar.*; > > /** >- * @author aniefer >+ * @author aniefer@ca.ibm.com > * > */ > public class Utils { >+ public static final String SIGN_EXCLUDES = "sign.excludes"; //$NON-NLS-1$ >+ public static final String PACK_EXCLUDES = "pack.excludes"; //$NON-NLS-1$ > public static final String MARK_FILE_NAME = "META-INF/eclipse.inf"; //$NON-NLS-1$ > public static final String MARK_PROPERTY = "pack200.conditioned"; //$NON-NLS-1$ >+ public static final String MARK_EXCLUDE = "jarprocessor.exclude"; //$NON-NLS-1$ >+ public static final String MARK_EXCLUDE_PACK = "jarprocessor.exclude.pack"; //$NON-NLS-1$ >+ public static final String MARK_EXCLUDE_SIGN = "jarprocessor.exclude.sign"; //$NON-NLS-1$ >+ public static final String MARK_JARPROCESSOR_VERSION = "jarprocessor.version"; //$NON-NLS-1$ >+ public static final String PACK_ARGS = "pack200.args"; //$NON-NLS-1$ >+ > public static final String PACK200_PROPERTY = "org.eclipse.update.jarprocessor.pack200"; //$NON-NLS-1$ > public static final String JRE = "@jre"; //$NON-NLS-1$ > public static final String PATH = "@path"; //$NON-NLS-1$ >@@ -151,7 +159,7 @@ > if (properties == null) > return Collections.EMPTY_SET; > >- String packExcludes = properties.getProperty("pack.excludes"); //$NON-NLS-1$ >+ String packExcludes = properties.getProperty(PACK_EXCLUDES); > if (packExcludes != null) { > String[] excludes = toStringArray(packExcludes, ","); //$NON-NLS-1$ > Set packExclusions = new HashSet(); >@@ -166,7 +174,7 @@ > public static Set getSignExclusions(Properties properties) { > if (properties == null) > return Collections.EMPTY_SET; >- String signExcludes = properties.getProperty("sign.excludes"); //$NON-NLS-1$ >+ String signExcludes = properties.getProperty(SIGN_EXCLUDES); > if (signExcludes != null) { > String[] excludes = toStringArray(signExcludes, ","); //$NON-NLS-1$ > Set signExclusions = new HashSet(); >@@ -193,40 +201,78 @@ > int count = tokenizer.countTokens(); > String[] result = new String[count]; > for (int i = 0; i < count; i++) { >- result[i] = tokenizer.nextToken(); >+ result[i] = tokenizer.nextToken().trim(); > } > return result; > } > >- public static boolean isUnmarkedJar(File jarFile) { >- if(jarFile == null || !jarFile.exists()) >- return false; >- >- boolean result = true; >- JarFile jar = null; >+ /** >+ * Get the properties from the eclipse.inf file from the given jar. If the file is not a jar, null is returned. >+ * If the file is a jar, but does not contain an eclipse.inf file, an empty Properties object is returned. >+ * @param jarFile >+ * @return >+ */ >+ public static Properties getEclipseInf(File jarFile) { >+ if (jarFile == null || !jarFile.exists()) >+ return null; > >+ JarFile jar = null; > try { > jar = new JarFile(jarFile, false); >- } catch (IOException e1) { >- //not a jar >- return false; >- } >- >- try { > JarEntry mark = jar.getJarEntry(MARK_FILE_NAME); > if (mark != null) { > InputStream in = jar.getInputStream(mark); > Properties props = new Properties(); > props.load(in); > in.close(); >- String value = props.getProperty(MARK_PROPERTY); >- result = !Boolean.valueOf(value).booleanValue(); >+ return props; > } >+ return new Properties(); > } catch (IOException e) { >- return false; >+ //not a jar > } finally { > close(jar); > } >- return result; >+ return null; >+ } >+ >+ public static boolean shouldSkipJar(File input, boolean processAll, boolean verbose) { >+ Properties inf = getEclipseInf(input); >+ if (inf == null) { >+ //not a jar, could be a pack.gz >+ return false; >+ } >+ String exclude = inf.getProperty(MARK_EXCLUDE); >+ >+ //was marked as exclude, we should skip >+ if (exclude != null && Boolean.valueOf(exclude).booleanValue()) >+ return true; >+ >+ //process all was set, don't skip >+ if (processAll) >+ return false; >+ >+ //otherwise, we skip if not marked marked >+ String marked = inf.getProperty(MARK_PROPERTY); >+ return !Boolean.valueOf(marked).booleanValue(); >+ } >+ >+ /** >+ * Stores the given properties in the output stream. We store the properties >+ * in sorted order so that the signing hash doesn't change if the properties didn't change. >+ * @param props >+ * @param stream >+ */ >+ public static void storeProperties(Properties props, OutputStream stream) { >+ PrintStream printStream = new PrintStream(stream); >+ printStream.println("#Processed using Jarprocessor"); //$NON-NLS-1$ >+ SortedMap sorted = new TreeMap(props); >+ for (Iterator iter = sorted.keySet().iterator(); iter.hasNext();) { >+ String key = (String) iter.next(); >+ printStream.print(key); >+ printStream.print(" = "); //$NON-NLS-1$ >+ printStream.println(sorted.get(key)); >+ } >+ printStream.flush(); > } > } >Index: src/org/eclipse/update/internal/jarprocessor/CommandStep.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/CommandStep.java,v >retrieving revision 1.2 >diff -u -r1.2 CommandStep.java >--- src/org/eclipse/update/internal/jarprocessor/CommandStep.java 21 Apr 2006 18:54:55 -0000 1.2 >+++ src/org/eclipse/update/internal/jarprocessor/CommandStep.java 31 Jul 2006 18:25:05 -0000 >@@ -10,10 +10,11 @@ > *******************************************************************************/ > package org.eclipse.update.internal.jarprocessor; > >+import java.io.File; > import java.util.Properties; > > /** >- * @author aniefer >+ * @author aniefer@ca.ibm.com > * > */ > public abstract class CommandStep implements IProcessStep { >@@ -60,4 +61,8 @@ > options = new Properties(); > return options; > } >+ >+ public void adjustInf(File input, Properties inf) { >+ //nothing >+ } > } >Index: src/org/eclipse/update/internal/jarprocessor/JarProcessor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/JarProcessor.java,v >retrieving revision 1.3 >diff -u -r1.3 JarProcessor.java >--- src/org/eclipse/update/internal/jarprocessor/JarProcessor.java 4 May 2006 20:12:44 -0000 1.3 >+++ src/org/eclipse/update/internal/jarprocessor/JarProcessor.java 31 Jul 2006 18:25:05 -0000 >@@ -15,7 +15,7 @@ > import java.util.jar.*; > > /** >- * @author aniefer >+ * @author aniefer@ca.ibm.com > * > */ > public class JarProcessor { >@@ -24,7 +24,6 @@ > private int depth = -1; > private boolean verbose = false; > private boolean processAll = false; >- private boolean shouldMarkJars = false; > > static public JarProcessor getUnpackProcessor(Properties properties) { > if (!canPerformUnpack()) >@@ -68,13 +67,10 @@ > > public void addProcessStep(IProcessStep step) { > steps.add(step); >- if(step instanceof PackUnpackStep) >- shouldMarkJars = true; > } > > public void clearProcessSteps() { > steps.clear(); >- shouldMarkJars = false; > } > > public void process(File input, FileFilter filter) throws FileNotFoundException { >@@ -114,7 +110,7 @@ > * @param directory - location to find file for new entryName > * @throws IOException > */ >- private void recreateJar(JarFile jar, JarOutputStream outputJar, Map replacements, File directory) throws IOException { >+ private void recreateJar(JarFile jar, JarOutputStream outputJar, Map replacements, File directory, Properties inf) throws IOException { > InputStream in = null; > boolean marked = false; > try { >@@ -133,13 +129,9 @@ > } > newEntry.setTime(entry.getTime()); > outputJar.putNextEntry(newEntry); >- if (shouldMarkJars && entry.getName().equals(Utils.MARK_FILE_NAME)) { >- Properties props = new Properties(); >- props.load(in); >- String val = props.getProperty(Utils.MARK_PROPERTY); >- if(val == null || !Boolean.valueOf(val).booleanValue()) >- props.setProperty(Utils.MARK_PROPERTY, "true"); //$NON-NLS-1$ >- props.store(outputJar, null); >+ if (entry.getName().equals(Utils.MARK_FILE_NAME)) { >+ //The eclipse.inf file was read in earlier, don't need to reread it, just write it out now >+ Utils.storeProperties(inf, outputJar); > marked = true; > } else { > Utils.transferStreams(in, outputJar, false); >@@ -152,12 +144,10 @@ > replacement.delete(); > } > } >- if (shouldMarkJars && !marked) { >+ if (!marked) { > JarEntry entry = new JarEntry(Utils.MARK_FILE_NAME); >- Properties props = new Properties(); >- props.setProperty(Utils.MARK_PROPERTY, "true"); //$NON-NLS-1$ > outputJar.putNextEntry(entry); >- props.store(outputJar, null); >+ Utils.storeProperties(inf, outputJar); > outputJar.closeEntry(); > } > } finally { >@@ -246,6 +236,13 @@ > return input; > } > >+ private void adjustInf(File input, Properties inf) { >+ for (Iterator iter = steps.iterator(); iter.hasNext();) { >+ IProcessStep step = (IProcessStep) iter.next(); >+ step.adjustInf(input, inf); >+ } >+ } >+ > public void processJar(File input) throws IOException { > ++depth; > long lastModified = input.lastModified(); >@@ -253,7 +250,7 @@ > if (!workingDir.exists()) > workingDir.mkdirs(); > >- boolean skip = !processAll && Utils.isUnmarkedJar(input); >+ boolean skip = Utils.shouldSkipJar(input, processAll, verbose); > if (depth == 0 && verbose) { > if (skip) > System.out.println("Skipping " + input.getPath()); //$NON-NLS-1$ >@@ -289,6 +286,10 @@ > Map replacements = new HashMap(); > extractEntries(jar, tempDir, replacements); > >+ Properties inf = Utils.getEclipseInf(workingFile); >+ if (inf != null) >+ adjustInf(workingFile, inf); >+ > //Recreate the jar with replacements. This also has the effect of normalizing the jar, so we want to do this even if > //we aren't actually replacing anything > File tempJar = null; >@@ -297,7 +298,7 @@ > if (!parent.exists()) > parent.mkdirs(); > JarOutputStream jarOut = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(tempJar))); >- recreateJar(jar, jarOut, replacements, tempDir); >+ recreateJar(jar, jarOut, replacements, tempDir, inf); > > jar.close(); > if (tempJar != null) { >Index: src/org/eclipse/update/internal/jarprocessor/PackStep.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/PackStep.java,v >retrieving revision 1.3 >diff -u -r1.3 PackStep.java >--- src/org/eclipse/update/internal/jarprocessor/PackStep.java 3 May 2006 18:33:20 -0000 1.3 >+++ src/org/eclipse/update/internal/jarprocessor/PackStep.java 31 Jul 2006 18:25:05 -0000 >@@ -71,9 +71,15 @@ > > public File postProcess(File input, File workingDirectory) { > if (canPack() && packCommand != null) { >+ Properties inf = Utils.getEclipseInf(input); >+ if (inf != null && inf.containsKey(Utils.MARK_EXCLUDE_PACK) && Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_PACK)).booleanValue()) { >+ if(verbose) >+ System.out.println("Excluding " + input.getName() + " from " + getStepName()); //$NON-NLS-1$ //$NON-NLS-2$ >+ return null; >+ } > File outputFile = new File(workingDirectory, input.getName() + Utils.PACKED_SUFFIX); > try { >- String[] cmd = getCommand(input, outputFile); >+ String[] cmd = getCommand(input, outputFile, inf); > int result = execute(cmd, verbose); > if (result != 0 && verbose) > System.out.println("Error: " + result + " was returned from command: " + Utils.concat(cmd)); //$NON-NLS-1$ //$NON-NLS-2$ >@@ -87,10 +93,15 @@ > return null; > } > >- protected String[] getCommand(File input, File outputFile) throws IOException { >+ protected String[] getCommand(File input, File outputFile, Properties inf) throws IOException { > String[] cmd = null; >- String arguments = getOptions().getProperty(input.getName() + ".pack.args"); //$NON-NLS-1$ >- if (arguments != null) { >+ String arguments = null; >+ if (inf != null && inf.containsKey(Utils.PACK_ARGS)) { >+ arguments = inf.getProperty(Utils.PACK_ARGS); >+ } else { >+ arguments = getOptions().getProperty(input.getName() + ".pack.args"); //$NON-NLS-1$ >+ } >+ if (arguments != null && arguments.length() > 0) { > String[] args = Utils.toStringArray(arguments, ","); //$NON-NLS-1$ > cmd = new String[3 + args.length]; > cmd[0] = packCommand; >@@ -106,4 +117,21 @@ > public String getStepName() { > return "Pack"; //$NON-NLS-1$ > } >+ >+ public void adjustInf(File input, Properties inf) { >+ if (input == null || inf == null) >+ return; >+ >+ if (inf.containsKey(Utils.MARK_EXCLUDE_PACK) && Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_PACK)).booleanValue()) { >+ return; >+ } >+ >+ inf.put(Utils.MARK_PROPERTY, "true"); //$NON-NLS-1$ >+ String arguments = inf.getProperty(Utils.PACK_ARGS); >+ if (arguments == null) { >+ arguments = getOptions().getProperty(input.getName() + ".pack.args"); //$NON-NLS-1$ >+ if (arguments != null) >+ inf.put(Utils.PACK_ARGS, arguments); >+ } >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 146066
:
46045
| 47083