diff --git a/WHATSNEW b/WHATSNEW index 0ae7100eb..3a3891d64 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -112,6 +112,9 @@ Fixed bugs: * file names that include spaces need to be quoted inside the @argfile argument using forked and JDK 1.4. Bugzilla Report 10499. +* Setting filesonly to true in and related tasks would cause the + archives to be always recreated. Bugzilla Report 19449. + Other changes: -------------- * Six new Clearcase tasks added. diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index ef00761dd..a4c0df8cb 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -812,6 +812,10 @@ public class Zip extends MatchingTask { initialResources[i], myMapper, getZipScanner()); + if (doFilesonly) { + newerResources[i] = selectFileResources(newerResources[i]); + } + needsUpdate = needsUpdate || (newerResources[i].length > 0); if (needsUpdate && !doUpdate) { @@ -1116,6 +1120,34 @@ public class Zip extends MatchingTask { return true; } + /** + * Drops all non-file resources from the given array. + * + * @since Ant 1.6 + */ + protected Resource[] selectFileResources(Resource[] orig) { + if (orig.length == 0) { + return orig; + } + + Vector v = new Vector(orig.length); + for (int i = 0; i < orig.length; i++) { + if (!orig[i].isDirectory()) { + v.addElement(orig[i]); + } else { + log("Ignoring directory " + orig[i].getName() + + " as only files will be added.", Project.MSG_VERBOSE); + } + } + + if (v.size() != orig.length) { + Resource[] r = new Resource[v.size()]; + v.copyInto(r); + return r; + } + return orig; + } + /** * Possible behaviors when a duplicate file is added: * "add", "preserve" or "fail"