You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2008/09/26 12:52:36 UTC

svn commit: r699263 - in /ant/core/trunk: WHATSNEW docs/manual/CoreTypes/mapper.html src/main/org/apache/tools/ant/util/CompositeMapper.java

Author: bodewig
Date: Fri Sep 26 03:52:36 2008
New Revision: 699263

URL: http://svn.apache.org/viewvc?rev=699263&view=rev
Log:
make order of compositemapper's results predictable.  PR 44873.

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/docs/manual/CoreTypes/mapper.html
    ant/core/trunk/src/main/org/apache/tools/ant/util/CompositeMapper.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=699263&r1=699262&r2=699263&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Sep 26 03:52:36 2008
@@ -382,6 +382,9 @@
    <signjar>.
    Bugzilla Report 39189.
 
+ * <compositemapper>'s order of results is now predictable.
+   Bugzilla Report 44873
+
 Changes from Ant 1.7.0 TO Ant 1.7.1
 =============================================
 

Modified: ant/core/trunk/docs/manual/CoreTypes/mapper.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTypes/mapper.html?rev=699263&r1=699262&r2=699263&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTypes/mapper.html (original)
+++ ant/core/trunk/docs/manual/CoreTypes/mapper.html Fri Sep 26 03:52:36 2008
@@ -629,6 +629,9 @@
     File mapping is performed by passing the source filename to each nested
     <code>&lt;mapper&gt;</code> in turn, returning all results.
     The <i>to</i> and <i>from</i> attributes are ignored.</p>
+  <p>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.</p>
 <b>Examples:</b>
 <blockquote><pre>
 &lt;compositemapper&gt;

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/CompositeMapper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/CompositeMapper.java?rev=699263&r1=699262&r2=699263&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/CompositeMapper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/CompositeMapper.java Fri Sep 26 03:52:36 2008
@@ -20,6 +20,7 @@
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedList;
 
 /**
  * A <CODE>ContainerMapper</CODE> that unites the results of its constituent
@@ -30,6 +31,7 @@
     /** {@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 @@
             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()]);
     }
 
 }