Browse Source

alphasort directories read from non-FileSet resource collections - DirectoryScanner already sorts them appropriately for FileSets

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@794214 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
4b52f604ad
1 changed files with 17 additions and 4 deletions
  1. +17
    -4
      src/main/org/apache/tools/ant/taskdefs/Zip.java

+ 17
- 4
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -26,6 +26,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
@@ -1523,18 +1525,29 @@ public class Zip extends MatchingTask {
Resource[][] result = new Resource[rcs.length][];
for (int i = 0; i < rcs.length; i++) {
Iterator iter = rcs[i].iterator();
ArrayList rs = new ArrayList();
int lastDir = 0;
ArrayList dirs = new ArrayList();
ArrayList files = new ArrayList();
while (iter.hasNext()) {
Resource r = (Resource) iter.next();
if (r.isExists()) {
if (r.isDirectory()) {
rs.add(lastDir++, r);
dirs.add(r);
} else {
rs.add(r);
files.add(r);
}
}
}
// make sure directories are in alpha-order - this also
// ensures parents come before their children
Collections.sort(dirs, new Comparator() {
public int compare(Object o1, Object o2) {
Resource r1 = (Resource) o1;
Resource r2 = (Resource) o2;
return r1.getName().compareTo(r2.getName());
}
});
ArrayList rs = new ArrayList(dirs);
rs.addAll(files);
result[i] = (Resource[]) rs.toArray(new Resource[rs.size()]);
}
return result;


Loading…
Cancel
Save