diff --git a/WHATSNEW b/WHATSNEW index 75d04dc34..6c737aaf7 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -382,6 +382,9 @@ Other changes: . Bugzilla Report 39189. + * 's order of results is now predictable. + Bugzilla Report 44873 + Changes from Ant 1.7.0 TO Ant 1.7.1 ============================================= diff --git a/docs/manual/CoreTypes/mapper.html b/docs/manual/CoreTypes/mapper.html index 365620930..e55652e60 100644 --- a/docs/manual/CoreTypes/mapper.html +++ b/docs/manual/CoreTypes/mapper.html @@ -629,6 +629,9 @@ with <uptodate> and <junit> output.

File mapping is performed by passing the source filename to each nested <mapper> in turn, returning all results. The to and from attributes are ignored.

+

Starting with Ant 1.8.0 the order of the mapped results is the + same as the order of the nested mappers; prior to Ant 1.8.0 the + order has been undefined.

Examples:
 <compositemapper>
diff --git a/src/main/org/apache/tools/ant/util/CompositeMapper.java b/src/main/org/apache/tools/ant/util/CompositeMapper.java
index 78f72e7e1..03b6b22b5 100755
--- a/src/main/org/apache/tools/ant/util/CompositeMapper.java
+++ b/src/main/org/apache/tools/ant/util/CompositeMapper.java
@@ -20,6 +20,7 @@ package org.apache.tools.ant.util;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedList;
 
 /**
  * A ContainerMapper that unites the results of its constituent
@@ -30,6 +31,7 @@ public class CompositeMapper extends ContainerMapper {
     /** {@inheritDoc}. */
     public String[] mapFileName(String sourceFileName) {
         HashSet results = new HashSet();
+        LinkedList sortedResults = new LinkedList();
 
         FileNameMapper mapper = null;
         for (Iterator mIter = getMappers().iterator(); mIter.hasNext();) {
@@ -37,12 +39,17 @@ public class CompositeMapper extends ContainerMapper {
             if (mapper != null) {
                 String[] mapped = mapper.mapFileName(sourceFileName);
                 if (mapped != null) {
-                    results.addAll(Arrays.asList(mapped));
+                    for (int i = 0; i < mapped.length; i++) {
+                        if (!results.contains(mapped[i])) {
+                            results.add(mapped[i]);
+                            sortedResults.addLast(mapped[i]);
+                        }
+                    }
                 }
             }
         }
         return (results.size() == 0) ? null
-            : (String[]) results.toArray(new String[results.size()]);
+            : (String[]) sortedResults.toArray(new String[results.size()]);
     }
 
 }