cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Jar.java
peterreilly2005/03/14 02:02:01 Modified:src/main/org/apache/tools/ant/taskdefs Jar.java Log: javadoc Revision ChangesPath 1.90 +58 -5 ant/src/main/org/apache/tools/ant/taskdefs/Jar.java Index: Jar.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Jar.java,v retrieving revision 1.89 retrieving revision 1.90 diff -u -r1.89 -r1.90 --- Jar.java 11 Mar 2005 08:41:41 - 1.89 +++ Jar.java 14 Mar 2005 10:02:00 - 1.90 @@ -151,6 +151,8 @@ } /** + * Not used for jar files. + * @param we not used * @ant.attribute ignore="true" */ public void setWhenempty(WhenEmpty we) { @@ -159,6 +161,8 @@ } /** + * Set the destination file. + * @param jarFile the destination file * @deprecated Use setDestFile(File) instead */ public void setJarfile(File jarFile) { @@ -168,14 +172,16 @@ /** * Set whether or not to create an index list for classes. * This may speed up classloading in some cases. + * @param flag a boolean value */ public void setIndex(boolean flag) { index = flag; } /** - * Set whether or not to create an index list for classes. - * This may speed up classloading in some cases. + * The character encoding to use in the manifest file. + * + * @param manifestEncoding the character encoding */ public void setManifestEncoding(String manifestEncoding) { this.manifestEncoding = manifestEncoding; @@ -185,8 +191,8 @@ * Allows the manifest for the archive file to be provided inline * in the build file rather than in an external file. * - * @param newManifest - * @throws ManifestException + * @param newManifest an embedded manifest element + * @throws ManifestException on error */ public void addConfiguredManifest(Manifest newManifest) throws ManifestException { @@ -331,6 +337,8 @@ } /** + * Add a path to index jars. + * @param p a path * @since Ant 1.6.2 */ public void addConfiguredIndexJars(Path p) { @@ -340,6 +348,12 @@ indexJars.append(p); } +/** + * Initialize the zip output stream. + * @param zOut the zip output stream + * @throws IOException on I/O errors + * @throws BuildException on other errors + */ protected void initZipOutputStream(ZipOutputStream zOut) throws IOException, BuildException { @@ -410,6 +424,13 @@ super.initZipOutputStream(zOut); } +/** + * Finalize the zip output stream. + * This creates an index list if the index attribute is true. + * @param zOut the zip output stream + * @throws IOException on I/O errors + * @throws BuildException on other errors + */ protected void finalizeZipOutputStream(ZipOutputStream zOut) throws IOException, BuildException { @@ -484,6 +505,14 @@ /** * Overridden from Zip class to deal with manifests and index lists. + * @param is the input stream + * @param zOut the zip output stream + * @param vPath the name this entry shall have in the archive + * @param lastModified last modification time for the entry. + * @param fromArchive the original archive we are copying this + *entry from, will be null if we are not copying from an archive. + * @param mode the Unix permissions to set. + * @throws IOException on error */ protected void zipFile(InputStream is, ZipOutputStream zOut, String vPath, long lastModified, File fromArchive, int mode) @@ -637,6 +666,12 @@ return super.getResourcesToAdd(filesets, zipFile, needsUpdate); } +/** + * Create an empty jar file. + * @param zipFile the file to create + * @return true for historic reasons + * @throws BuildException on error + */ protected boolean createEmptyZip(File zipFile) throws BuildException { if (!createEmpty) { return true; @@ -667,6 +702,7 @@ zOut.close(); } } catch (IOException ex) { +// Ignore close exception } createEmpty = false; } @@ -708,7 +744,14 @@ index = false; } +/** + * The manifest config enumerated type. + */ public static class FilesetManifestConfig extends EnumeratedAttribute { +/** + * Get the list of valid strings. + * @return the list of values - "skip", "merge" and "mergewithoutmain" + */
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Jar.java
bodewig 2004/05/13 00:05:03 Modified:.WHATSNEW docs/manual/CoreTasks jar.html src/main/org/apache/tools/ant/taskdefs Jar.java Log: Add docs for Revision ChangesPath 1.605 +4 -0 ant/WHATSNEW Index: WHATSNEW === RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.604 retrieving revision 1.605 diff -u -r1.604 -r1.605 --- WHATSNEW 28 Apr 2004 18:08:47 - 1.604 +++ WHATSNEW 13 May 2004 07:05:00 - 1.605 @@ -128,6 +128,10 @@ * JDependTask did not close an output file. Bugzilla Report 28557. +* can now optionally create an index for jars different than the + one it currently builds as well. See the new element + for details. Bugzilla Report 14255. + Other changes: -- 1.31 +33 -1 ant/docs/manual/CoreTasks/jar.html Index: jar.html === RCS file: /home/cvs/ant/docs/manual/CoreTasks/jar.html,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- jar.html 27 Feb 2004 14:17:41 - 1.30 +++ jar.html 13 May 2004 07:05:02 - 1.31 @@ -160,7 +160,13 @@ index -whether to create an http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#JAR%20Index";>index list to speed up classloading. This is a JDK 1.3+ specific feature. Defaults to false. +whether to create an http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#JAR%20Index";>index +list to speed up classloading. This is a JDK 1.3+ specific +feature. Unless you specify additional jars with nested indexjars elements, only the +contents of this jar will be included in the index. Defaults to +false. No @@ -209,6 +215,32 @@ If the manifest values have changed the jar will be updated or rebuilt, as appropriate. + +indexjars + +since ant 1.6.2 + +The nested indexjars element specifies a PATH like structure. Its content is +completely ignored unless you set the index attribute of the task to +true. + +The index created by this task will contain indices for the +archives contained in this path, the names used for the archioves +depend on your manifest: + + If the generated jar's manifest contains no Class-Path + attribute, the file name without any leading directory path will be + used and all parts of the path will get indexed. + If the manifest contains a Class-Path attribute, this task will + try to guess which part of the Class-Path belongs to a given + archive. If it cannot guess a name, the archive will be skipped, + otherwise tha name listed inside the Class-PAth attribute will be + used. + + +This task will not create any index entries for archives that are +empty or only contain files inside the META-INF directory. Examples1.87 +4 -4 ant/src/main/org/apache/tools/ant/taskdefs/Jar.java Index: Jar.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Jar.java,v retrieving revision 1.86 retrieving revision 1.87 diff -u -r1.86 -r1.87 --- Jar.java 23 Apr 2004 10:03:49 - 1.86 +++ Jar.java 13 May 2004 07:05:02 - 1.87 @@ -126,7 +126,7 @@ /** * Path containing jars that shall be indexed in addition to this archive. * - * @since Ant 1.7 + * @since Ant 1.6.2 */ private Path indexJars; @@ -320,7 +320,7 @@ } /** - * @since Ant 1.7 + * @since Ant 1.6.2 */ public void addConfiguredIndexJars(Path p) { if (indexJars == null) { @@ -706,7 +706,7 @@ * Writes the directory entries from the first and the filenames * from the second list to the given writer, one entry per line. * - * @since Ant 1.7 + * @since Ant 1.6.2 */ protected final void writeIndexLikeList(List dirs, List files, PrintWriter writer) @@ -764,7 +764,7 @@ * if there is a classpath and the given file doesn't match any * of its entries, return null. * - * @since Ant 1.7 + * @since Ant 1.6.2 */ protected static final String findJarName(String fileName, String[] classpath) { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Jar.java
bodewig 2003/04/02 22:41:51 Modified:.WHATSNEW src/main/org/apache/tools/ant/taskdefs Jar.java Log: Improve standards compliance of created index. PR: 16972 Revision ChangesPath 1.387 +3 -0 ant/WHATSNEW Index: WHATSNEW === RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.386 retrieving revision 1.387 diff -u -r1.386 -r1.387 --- WHATSNEW 2 Apr 2003 16:01:15 - 1.386 +++ WHATSNEW 3 Apr 2003 06:41:50 - 1.387 @@ -84,6 +84,9 @@ * could include multiple index lists. Bugzilla 10262. +* The index created by didn't conform to the spec as it didn't + include the top-level entries. Bugzilla Report 16972. + Other changes: -- * Shipped XML parser is now Xerces 2.4.0 1.74 +28 -7 ant/src/main/org/apache/tools/ant/taskdefs/Jar.java Index: Jar.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Jar.java,v retrieving revision 1.73 retrieving revision 1.74 diff -u -r1.73 -r1.74 --- Jar.java 2 Apr 2003 16:01:15 - 1.73 +++ Jar.java 3 Apr 2003 06:41:51 - 1.74 @@ -67,6 +67,7 @@ import java.io.PrintWriter; import java.io.Reader; import java.util.Enumeration; +import java.util.Vector; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import org.apache.tools.ant.BuildException; @@ -145,12 +146,24 @@ */ private boolean createEmpty = false; +/** + * Stores all files that are in the root of the archive (i.e. that + * have a name that doesn't contain a slash) so they can get + * listed in the index. + * + * Will not be filled unless the user has asked for an index. + * + * @since Ant 1.6 + */ +private Vector rootEntries; + /** constructor */ public Jar() { super(); archiveType = "jar"; emptyBehavior = "create"; setEncoding("UTF8"); +rootEntries = new Vector(); } /** @@ -458,6 +471,11 @@ writer.println(dir); } +enum = rootEntries.elements(); +while (enum.hasMoreElements()) { +writer.println(enum.nextElement()); +} + writer.flush(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); @@ -480,6 +498,9 @@ + " files include a META-INF/INDEX.LIST which will" + " be replaced by a newly generated one.", Project.MSG_WARN); } else { +if (index && vPath.indexOf("/") == -1) { +rootEntries.addElement(vPath); +} super.zipFile(is, zOut, vPath, lastModified, fromArchive, mode); } } @@ -663,13 +684,13 @@ super.cleanUp(); // we want to save this info if we are going to make another pass -if (! doubleFilePass || (doubleFilePass && ! skipWriting)) -{ -manifest = null; -configuredManifest = savedConfiguredManifest; -filesetManifest = null; -originalManifest = null; -} +if (! doubleFilePass || (doubleFilePass && ! skipWriting)) { +manifest = null; +configuredManifest = savedConfiguredManifest; +filesetManifest = null; +originalManifest = null; +} +rootEntries.removeAllElements(); } /**
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Jar.java
bodewig 2003/04/02 08:01:15 Modified:.WHATSNEW src/main/org/apache/tools/ant/taskdefs Jar.java Log: Ignore index lists found when creating a jar with index="on". PR: 10262 Revision ChangesPath 1.386 +2 -0 ant/WHATSNEW Index: WHATSNEW === RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.385 retrieving revision 1.386 diff -u -r1.385 -r1.386 --- WHATSNEW 2 Apr 2003 14:53:20 - 1.385 +++ WHATSNEW 2 Apr 2003 16:01:15 - 1.386 @@ -82,6 +82,8 @@ * will now work on Unices with /bin/env instead of /usr/bin/env. Bugzilla Report 17642. +* could include multiple index lists. Bugzilla 10262. + Other changes: -- * Shipped XML parser is now Xerces 2.4.0 1.73 +5 -1 ant/src/main/org/apache/tools/ant/taskdefs/Jar.java Index: Jar.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Jar.java,v retrieving revision 1.72 retrieving revision 1.73 diff -u -r1.72 -r1.73 --- Jar.java 22 Mar 2003 09:39:46 - 1.72 +++ Jar.java 2 Apr 2003 16:01:15 - 1.73 @@ -466,7 +466,7 @@ } /** - * Overriden from Zip class to deal with manifests + * Overriden from Zip class to deal with manifests and index lists. */ protected void zipFile(InputStream is, ZipOutputStream zOut, String vPath, long lastModified, File fromArchive, int mode) @@ -475,6 +475,10 @@ if (! doubleFilePass || (doubleFilePass && skipWriting)) { filesetManifest(fromArchive, is); } +} else if (INDEX_NAME.equalsIgnoreCase(vPath) && index) { +log("Warning: selected " + archiveType ++ " files include a META-INF/INDEX.LIST which will" ++ " be replaced by a newly generated one.", Project.MSG_WARN); } else { super.zipFile(is, zOut, vPath, lastModified, fromArchive, mode); }
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Jar.java ManifestTask.java
conor 2003/03/22 01:53:16 Modified:docs/manual/CoreTasks Tag: ANT_15_BRANCH jar.html manifest.html src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH Jar.java ManifestTask.java Log: Merge Revision ChangesPath No revision No revision 1.16.2.7 +5 -0 ant/docs/manual/CoreTasks/jar.html Index: jar.html === RCS file: /home/cvs/ant/docs/manual/CoreTasks/jar.html,v retrieving revision 1.16.2.6 retrieving revision 1.16.2.7 diff -u -w -u -r1.16.2.6 -r1.16.2.7 --- jar.html 19 Feb 2003 08:13:58 - 1.16.2.6 +++ jar.html 22 Mar 2003 09:53:15 - 1.16.2.7 @@ -144,6 +144,11 @@ whether to create an http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#JAR%20Index";>index list to speed up classloading. This is a JDK 1.3+ specific feature. Defaults to false. No + +manifestencoding +The encoding used to read the JAR manifest, when a manifest file is specified. +No, defaults to the platform encoding. + Nested elements 1.4.2.3 +5 -0 ant/docs/manual/CoreTasks/manifest.html Index: manifest.html === RCS file: /home/cvs/ant/docs/manual/CoreTasks/manifest.html,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -u -w -u -r1.4.2.2 -r1.4.2.3 --- manifest.html 4 Sep 2002 11:21:12 - 1.4.2.2 +++ manifest.html 22 Mar 2003 09:53:15 - 1.4.2.3 @@ -39,6 +39,11 @@ One of "update" or "replace", default is "replace". No + +encoding +The encoding used to read the existing manifest when updating. +No, defaults to UTF-8 encoding. + Nested elements No revision No revision 1.51.2.18 +45 -7 ant/src/main/org/apache/tools/ant/taskdefs/Jar.java Index: Jar.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Jar.java,v retrieving revision 1.51.2.17 retrieving revision 1.51.2.18 diff -u -w -u -r1.51.2.17 -r1.51.2.18 --- Jar.java 12 Mar 2003 11:29:10 - 1.51.2.17 +++ Jar.java 22 Mar 2003 09:53:15 - 1.51.2.18 @@ -61,6 +61,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; @@ -129,6 +130,9 @@ /** the manifest specified by the 'manifest' attribute **/ private Manifest manifest; +/** The encoding to use when reading in a manifest file */ +private String manifestEncoding; + /** * The file found from the 'manifest' attribute. This can be * either the location of a manifest, or the name of a jar added @@ -178,6 +182,14 @@ } /** + * Set whether or not to create an index list for classes. + * This may speed up classloading in some cases. + */ +public void setManifestEncoding(String manifestEncoding) { +this.manifestEncoding = manifestEncoding; +} + +/** * Allows the manifest for the archive file to be provided inline * in the build file rather than in an external file. * @@ -217,8 +229,15 @@ InputStreamReader isr = null; try { fis = new FileInputStream(manifestFile); -isr = new InputStreamReader(fis, "UTF-8"); +if (manifestEncoding == null) { +isr = new InputStreamReader(fis); +} else { +isr = new InputStreamReader(fis, manifestEncoding); +} newManifest = getManifest(isr); +} catch (UnsupportedEncodingException e) { +throw new BuildException("Unsupported encoding while reading manifest: " + + e.getMessage(), e); } catch (IOException e) { throw new BuildException("Unable to read manifest file: " + manifestFile @@ -470,11 +489,22 @@ // If this is the same name specified in 'manifest', this // is the manifest to use log("Found manifest " + file, Project.MSG_VERBOSE); +try { if (is != null) { -manifest = getManifest(new InputStreamReader(is, "UTF-8")); +InputStreamReader isr; +if (manifestEncoding == null) { +isr = new InputStreamReader(is); +} else { +
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Jar.java ManifestTask.java
conor 2003/03/22 01:39:46 Modified:src/main/org/apache/tools/ant/loader AntClassLoader2.java docs/manual/CoreTasks jar.html manifest.html src/main/org/apache/tools/ant/taskdefs Jar.java ManifestTask.java Log: Add manifest encoding options to control the encoding used to read in manifests PR: 17634 Revision ChangesPath 1.6 +2 -1 ant/src/main/org/apache/tools/ant/loader/AntClassLoader2.java Index: AntClassLoader2.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/loader/AntClassLoader2.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -u -r1.5 -r1.6 --- AntClassLoader2.java 10 Feb 2003 14:13:34 - 1.5 +++ AntClassLoader2.java 22 Mar 2003 09:39:46 - 1.6 @@ -283,7 +283,8 @@ if (manifestStream == null) { return; } -Reader manifestReader = new InputStreamReader(manifestStream); +Reader manifestReader += new InputStreamReader(manifestStream, "UTF-8"); org.apache.tools.ant.taskdefs.Manifest manifest = new org.apache.tools.ant.taskdefs.Manifest(manifestReader); classpath 1.25 +5 -0 ant/docs/manual/CoreTasks/jar.html Index: jar.html === RCS file: /home/cvs/ant/docs/manual/CoreTasks/jar.html,v retrieving revision 1.24 retrieving revision 1.25 diff -u -w -u -r1.24 -r1.25 --- jar.html 7 Mar 2003 14:48:52 - 1.24 +++ jar.html 22 Mar 2003 09:39:46 - 1.25 @@ -151,6 +151,11 @@ whether to create an http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#JAR%20Index";>index list to speed up classloading. This is a JDK 1.3+ specific feature. Defaults to false. No + +manifestencoding +The encoding used to read the JAR manifest, when a manifest file is specified. +No, defaults to the platform encoding. + Nested elements 1.7 +5 -0 ant/docs/manual/CoreTasks/manifest.html Index: manifest.html === RCS file: /home/cvs/ant/docs/manual/CoreTasks/manifest.html,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -u -r1.6 -r1.7 --- manifest.html 4 Sep 2002 11:05:16 - 1.6 +++ manifest.html 22 Mar 2003 09:39:46 - 1.7 @@ -39,6 +39,11 @@ One of "update" or "replace", default is "replace". No + +encoding +The encoding used to read the existing manifest when updating. +No, defaults to UTF-8 encoding. + Nested elements 1.72 +45 -7 ant/src/main/org/apache/tools/ant/taskdefs/Jar.java Index: Jar.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Jar.java,v retrieving revision 1.71 retrieving revision 1.72 diff -u -w -u -r1.71 -r1.72 --- Jar.java 12 Mar 2003 11:23:27 - 1.71 +++ Jar.java 22 Mar 2003 09:39:46 - 1.72 @@ -61,6 +61,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; @@ -124,6 +125,9 @@ /** the manifest specified by the 'manifest' attribute **/ private Manifest manifest; +/** The encoding to use when reading in a manifest file */ +private String manifestEncoding; + /** * The file found from the 'manifest' attribute. This can be * either the location of a manifest, or the name of a jar added @@ -173,6 +177,14 @@ } /** + * Set whether or not to create an index list for classes. + * This may speed up classloading in some cases. + */ +public void setManifestEncoding(String manifestEncoding) { +this.manifestEncoding = manifestEncoding; +} + +/** * Allows the manifest for the archive file to be provided inline * in the build file rather than in an external file. * @@ -212,8 +224,15 @@ InputStreamReader isr = null; try { fis = new FileInputStream(manifestFile); -isr = new InputStreamReader(fis, "UTF-8"); +if (manifestEncoding == null) { +isr = new InputStreamReader(fis); +} else { +isr = new InputStreamReader(fis, manifestEncoding); +} newManifest = getManifest(isr); +} catch (UnsupportedEncodingException e) { +
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Jar.java Zip.java
bodewig 2003/03/12 03:23:28 Modified:src/main/org/apache/tools/ant/taskdefs Jar.java Zip.java Log: Fix the bug. PR: 17780 Revision ChangesPath 1.71 +5 -3 ant/src/main/org/apache/tools/ant/taskdefs/Jar.java Index: Jar.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Jar.java,v retrieving revision 1.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- Jar.java 17 Feb 2003 14:00:34 - 1.70 +++ Jar.java 12 Mar 2003 11:23:27 - 1.71 @@ -531,11 +531,12 @@ * out-of-date. Subclasses overriding this method are supposed to * set this value correctly in their call to * super.getResourcesToAdd. - * @return an array of resources to add for each fileset passed in. + * @return an array of resources to add for each fileset passed in as well + * as a flag that indicates whether the archive is uptodate. * * @exception BuildException if it likes */ -protected Resource[][] getResourcesToAdd(FileSet[] filesets, +protected ArchiveState getResourcesToAdd(FileSet[] filesets, File zipFile, boolean needsUpdate) throws BuildException { @@ -581,7 +582,8 @@ ZipOutputStream zOut = null; try { -log("Building jar: " + getDestFile().getAbsolutePath()); +log("Building MANIFEST-only jar: " ++ getDestFile().getAbsolutePath()); zOut = new ZipOutputStream(new FileOutputStream(getDestFile())); zOut.setEncoding(getEncoding()); 1.101 +64 -11ant/src/main/org/apache/tools/ant/taskdefs/Zip.java Index: Zip.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v retrieving revision 1.100 retrieving revision 1.101 diff -u -r1.100 -r1.101 --- Zip.java 7 Mar 2003 11:23:03 - 1.100 +++ Zip.java 12 Mar 2003 11:23:27 - 1.101 @@ -344,7 +344,11 @@ // we don't need to update if the original file doesn't exist addingNewFiles = true; -doUpdate = doUpdate && zipFile.exists(); +if (doUpdate && !zipFile.exists()) { +doUpdate = false; +log("ignoring update attribute as " + archiveType ++ " doesn't exist.", Project.MSG_DEBUG); +} // Add the files found in groupfileset to fileset for (int i = 0; i < groupfilesets.size(); i++) { @@ -381,14 +385,16 @@ vfss.copyInto(fss); boolean success = false; try { -Resource[][] addThem = getResourcesToAdd(fss, zipFile, false); +// can also handle empty archives +ArchiveState state = getResourcesToAdd(fss, zipFile, false); // quick exit if the target is up to date -// can also handle empty archives -if (isEmpty(addThem)) { +if (!state.isOutOfDate()) { return; } +Resource[][] addThem = state.getResourcesToAdd(); + if (doUpdate) { renamedFile = fileUtils.createTempFile("zip", ".tmp", @@ -687,17 +693,38 @@ * out-of-date. Subclasses overriding this method are supposed to * set this value correctly in their call to * super.getResourcesToAdd. - * @return an array of resources to add for each fileset passed in. + * @return an array of resources to add for each fileset passed in as well + * as a flag that indicates whether the archive is uptodate. * * @exception BuildException if it likes */ -protected Resource[][] getResourcesToAdd(FileSet[] filesets, +protected ArchiveState getResourcesToAdd(FileSet[] filesets, File zipFile, boolean needsUpdate) throws BuildException { Resource[][] initialResources = grabResources(filesets); if (isEmpty(initialResources)) { +if (needsUpdate && doUpdate) { +/* + * This is a rather hairy case. + * + * One of our subclasses knows that we need to update the + * archive, but at the same time, there are no resources + * known to us that would need to be added. Only the + * subclass seems to know what's going on. + * + * This happens if detects that the manifest has changed, + * for example. The manifest is not