Browse Source

Don't update archives because it lacks directory entries when we are

not going to add directory entries either.

PR: 19449


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274543 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
9e9ac87387
2 changed files with 35 additions and 0 deletions
  1. +3
    -0
      WHATSNEW
  2. +32
    -0
      src/main/org/apache/tools/ant/taskdefs/Zip.java

+ 3
- 0
WHATSNEW View File

@@ -112,6 +112,9 @@ Fixed bugs:
* file names that include spaces need to be quoted inside the @argfile
argument using forked <javac> and JDK 1.4. Bugzilla Report 10499.

* Setting filesonly to true in <zip> and related tasks would cause the
archives to be always recreated. Bugzilla Report 19449.

Other changes:
--------------
* Six new Clearcase tasks added.


+ 32
- 0
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -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"


Loading…
Cancel
Save