Author: bodewig
Date: Mon Sep 14 04:18:26 2009
New Revision: 814471
URL: http://svn.apache.org/viewvc?rev=814471&view=rev
Log:
Make sorting a separate step
Modified:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
Modified:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java?rev=814471&r1=814470&r2=814471&view=diff
==============================================================================
---
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
(original)
+++
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
Mon Sep 14 04:18:26 2009
@@ -23,6 +23,7 @@
import java.io.InputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
@@ -259,13 +260,13 @@
mode = new Mode();
mode.setValue(Mode.FORCE_CREATE);
}
- ResourceWithFlags[] toAdd;
+ ResourceWithFlags[] sourceResources;
try {
- toAdd = findSources();
+ sourceResources = findSources();
} catch (IOException ioex) {
throw new BuildException("Failed to read sources", ioex);
}
- if (toAdd.length == 0) {
+ if (sourceResources.length == 0) {
if (WhenEmpty.SKIP.equals(emptyBehavior.getValue())) {
log(NO_SOURCES_MSG, Project.MSG_WARN);
} else {
@@ -280,12 +281,20 @@
fileSetBuilder.buildFileSet(destOrCopy);
try {
- if (checkAndLogUpToDate(toAdd, targetArchive,
+ List/*<ResourceWithFlags>*/ toAdd
+ = new ArrayList/*<ResourceWithFlags>*/();
+ toAdd.addAll(Arrays.asList(sourceResources));
+
+ if (checkAndLogUpToDate(sourceResources, targetArchive,
existingEntries)) {
return;
}
+
+ sort(toAdd);
+
try {
- writeArchive(toAdd);
+ writeArchive((ResourceWithFlags[])
+ toAdd.toArray(new ResourceWithFlags[0]));
} catch (IOException ioex) {
throw new BuildException("Failed to write archive", ioex);
}
@@ -346,13 +355,6 @@
}
}
}
- Collections.sort(l, new Comparator/*<ResourceWithFlags>*/() {
- public int compare(Object o1, Object o2) {
- ResourceWithFlags r1 = (ResourceWithFlags) o1;
- ResourceWithFlags r2 = (ResourceWithFlags) o2;
- return r1.getName().compareTo(r2.getName());
- }
- });
return (ResourceWithFlags[]) l.toArray(new
ResourceWithFlags[l.size()]);
}
@@ -402,6 +404,19 @@
}
/**
+ * Sorts the list of resources to add.
+ */
+ protected void sort(List/*<ResourceWithFlags>*/ l) {
+ Collections.sort(l, new Comparator/*<ResourceWithFlags>*/() {
+ public int compare(Object o1, Object o2) {
+ ResourceWithFlags r1 = (ResourceWithFlags) o1;
+ ResourceWithFlags r2 = (ResourceWithFlags) o2;
+ return r1.getName().compareTo(r2.getName());
+ }
+ });
+ }
+
+ /**
* Creates the archive archiving the given resources.
*/
protected void writeArchive(ResourceWithFlags[] src)