ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r818389 - in /ant/core/trunk: WHATSNEW src/etc/testcases/taskdefs/pathconvert.xml src/main/org/apache/tools/ant/util/GlobPatternMapper.java src/tests/antunit/types/glob-test.xml
Date Thu, 24 Sep 2009 07:29:34 GMT
Author: bodewig
Date: Thu Sep 24 07:29:33 2009
New Revision: 818389

URL: http://svn.apache.org/viewvc?rev=818389&view=rev
Log:
GlobMapper's from attribute was broken, too

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/etc/testcases/taskdefs/pathconvert.xml
    ant/core/trunk/src/main/org/apache/tools/ant/util/GlobPatternMapper.java
    ant/core/trunk/src/tests/antunit/types/glob-test.xml

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=818389&r1=818388&r2=818389&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Sep 24 07:29:33 2009
@@ -134,10 +134,11 @@
    versions of Ant.
    Bugzilla Report 36748.
 
- * globmapper didn't work properly if the "to" pattern didn't contain
-   a "*".  In particular it implicitly added a * to the end of the
-   pattern.  This is no longer the case.  If you relied on this
-   behavior you will now need to explicitly specify the trailing *.
+ * globmapper didn't work properly if the "to" or "from" patterns
+   didn't contain a "*".  In particular it implicitly added a * to the
+   end of the pattern(s).  This is no longer the case.  If you relied
+   on this behavior you will now need to explicitly specify the
+   trailing "*".
    Bugzilla Report 46506.
 
  * <copy> silently ignored missing resources even with

Modified: ant/core/trunk/src/etc/testcases/taskdefs/pathconvert.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/pathconvert.xml?rev=818389&r1=818388&r2=818389&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/pathconvert.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/pathconvert.xml Thu Sep 24 07:29:33 2009
@@ -31,7 +31,7 @@
     <target name="testmapper">
         <pathconvert property="result" dirsep="#">
             <path refid="testpath" />
-            <mapper type="glob" from="${basedir}" to="test*" />
+            <mapper type="glob" from="${basedir}*" to="test*" />
         </pathconvert>
     </target>
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/GlobPatternMapper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/GlobPatternMapper.java?rev=818389&r1=818388&r2=818389&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/GlobPatternMapper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/GlobPatternMapper.java Thu Sep 24 07:29:33
2009
@@ -68,6 +68,7 @@
 
     // CheckStyle:VisibilityModifier ON
 
+    private boolean fromContainsStar = false;
     private boolean toContainsStar = false;
     private boolean handleDirSep = false;
     private boolean caseSensitive = true;
@@ -106,6 +107,7 @@
             } else {
                 fromPrefix = from.substring(0, index);
                 fromPostfix = from.substring(index + 1);
+                fromContainsStar = true;
             }
             prefixLength = fromPrefix.length();
             postfixLength = fromPostfix.length();
@@ -142,10 +144,16 @@
      * @return a list of converted filenames
      */
     public String[] mapFileName(String sourceFileName) {
+        String modName = modifyName(sourceFileName);
         if (fromPrefix == null
-            || !modifyName(sourceFileName).startsWith(modifyName(fromPrefix))
-            || !modifyName(sourceFileName).endsWith(modifyName(fromPostfix))
             || (sourceFileName.length() < (prefixLength + postfixLength))
+            || (!fromContainsStar
+                && !modName.equals(modifyName(fromPrefix))
+                )
+            || (fromContainsStar
+                && (!modName.startsWith(modifyName(fromPrefix))
+                    || !modName.endsWith(modifyName(fromPostfix)))
+                )
             ) {
             return null;
         }

Modified: ant/core/trunk/src/tests/antunit/types/glob-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/types/glob-test.xml?rev=818389&r1=818388&r2=818389&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/types/glob-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/types/glob-test.xml Thu Sep 24 07:29:33 2009
@@ -68,4 +68,13 @@
     <au:assertFileExists file="${output}/c.jar-b"/>
   </target>
 
+  <target name="test-no-*-in-from" depends="setUp">
+    <touch file="${input}/a-b.jar"/>
+    <copy todir="${output}">
+      <fileset dir="${input}"/>
+      <mapper type="glob" from="a-b" to="c.jar"/>
+    </copy>
+    <au:assertFileDoesntExist file="${output}/c.jar"/>
+  </target>
+
 </project>



Mime
View raw message