You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2003/07/29 11:10:08 UTC
cvs commit: ant/src/main/org/apache/tools/ant/types Resource.java ZipScanner.java
bodewig 2003/07/29 02:10:08
Modified: src/main/org/apache/tools/ant DirectoryScanner.java
src/main/org/apache/tools/ant/types Resource.java
ZipScanner.java
Log:
Some tasks rely on the DFS ordering getIncludedXYZ used to provide
Revision Changes Path
1.59 +3 -0 ant/src/main/org/apache/tools/ant/DirectoryScanner.java
Index: DirectoryScanner.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/DirectoryScanner.java,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- DirectoryScanner.java 25 Jul 2003 18:40:53 -0000 1.58
+++ DirectoryScanner.java 29 Jul 2003 09:10:07 -0000 1.59
@@ -56,6 +56,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
@@ -1032,6 +1033,7 @@
public String[] getIncludedFiles() {
String[] files = new String[filesIncluded.size()];
filesIncluded.copyInto(files);
+ Arrays.sort(files);
return files;
}
@@ -1099,6 +1101,7 @@
public String[] getIncludedDirectories() {
String[] directories = new String[dirsIncluded.size()];
dirsIncluded.copyInto(directories);
+ Arrays.sort(directories);
return directories;
}
1.5 +14 -1 ant/src/main/org/apache/tools/ant/types/Resource.java
Index: Resource.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/Resource.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Resource.java 17 Feb 2003 12:59:23 -0000 1.4
+++ Resource.java 29 Jul 2003 09:10:07 -0000 1.5
@@ -63,7 +63,7 @@
* @author <a href="mailto:levylambert@tiscali-dsl.de">Antoine Levy-Lambert</a>
* @since Ant 1.5.2
*/
-public class Resource implements Cloneable {
+public class Resource implements Cloneable, Comparable {
private String name = null;
private boolean exists = true;
private long lastmodified = 0;
@@ -179,4 +179,17 @@
}
}
+ /**
+ * delegates to a comparison of names.
+ *
+ * @since Ant 1.6
+ */
+ public int compareTo(Object other) {
+ if (!(other instanceof Resource)) {
+ throw new IllegalArgumentException("Can only be compared with "
+ + "Resources");
+ }
+ Resource r = (Resource) other;
+ return getName().compareTo(r.getName());
+ }
}
1.21 +3 -0 ant/src/main/org/apache/tools/ant/types/ZipScanner.java
Index: ZipScanner.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/ZipScanner.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ZipScanner.java 15 Jul 2003 14:54:14 -0000 1.20
+++ ZipScanner.java 29 Jul 2003 09:10:07 -0000 1.21
@@ -56,6 +56,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration;
@@ -138,6 +139,7 @@
}
String[] files = new String[myvector.size()];
myvector.copyInto(files);
+ Arrays.sort(files);
return files;
} else {
return super.getIncludedFiles();
@@ -165,6 +167,7 @@
}
String[] files = new String[myvector.size()];
myvector.copyInto(files);
+ Arrays.sort(files);
return files;
} else {
return super.getIncludedDirectories();
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: cvs commit: ant/src/main/org/apache/tools/ant/types Resource.java ZipScanner.java
Posted by Stefan Bodewig <bo...@apache.org>.
On 29 Jul 2003, <bo...@apache.org> wrote:
> Some tasks rely on the DFS ordering getIncludedXYZ used to provide
I'm not sure whether we want to provide this as the sort order has
never been documented.
The recent changes in DirectoryScanner could lead to a situation in
which A/C will be returned before A/B, I don't think this is a big
issue but patched it for completeness.
The change to ZipScanner in turn is necessary as
getIncludedDirectories could return A/B before returning A itself -
this could cause trouble within Zip where the code assumes that the
parents of a given directory have been added before the directory
itself[1].
The change to Resource is merely cosmetic.
Stefan
Footnotes:
[1] Not strictly true, the code will ensure that the parents have been
added before, but may do the wrong thing WRT to Unix permissions once
my next patch to Zip is committed.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org