ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r955896 - in /ant/core/trunk: WHATSNEW docs/manual/using.html src/main/org/apache/tools/ant/types/Path.java src/tests/antunit/types/path-test.xml
Date Fri, 18 Jun 2010 09:03:34 GMT
Author: bodewig
Date: Fri Jun 18 09:03:34 2010
New Revision: 955896

URL: http://svn.apache.org/viewvc?rev=955896&view=rev
Log:
Support wildcards in CLASSPATH.  PR 46842.  Based on patch by Mike Murray.

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/docs/manual/using.html
    ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java
    ant/core/trunk/src/tests/antunit/types/path-test.xml

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=955896&r1=955895&r2=955896&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Jun 18 09:03:34 2010
@@ -87,6 +87,14 @@ Other changes:
    earlier -propertfiles or defined via the -D option).
    Bugzilla Report 18732.
 
+ * <pathelement>s can now contain wildcards in order to use wildcard
+   CLASSPATH entries introduced with Java6.
+   The wildcards are not expanded or even evaluated by Ant and will be
+   used literally.  The resulting path may be unusable as a CLASSPATH
+   for Java versions prior to Java6 and likely doesn't mean anything
+   when used in any other way than a CLASSPATH for a forked Java VM. 
+   Bugzilla Report 46842.
+
 Changes from Ant 1.8.0 TO Ant 1.8.1 
 ===================================
 

Modified: ant/core/trunk/docs/manual/using.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/using.html?rev=955896&r1=955895&r2=955896&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/using.html (original)
+++ ant/core/trunk/docs/manual/using.html Fri Jun 18 09:03:34 2010
@@ -262,6 +262,12 @@ or semicolon-separated lists of location
 attribute is intended to be used with predefined paths - in any other
 case, multiple elements with <code>location</code> attributes should be
 preferred.</p>
+<p><em>Since Ant 1.8.2</em> the location attribute can also contain a
+  wildcard in its last path component (i.e. it can end in a
+  &quot;*&quot;) in order to support wildcard CLASSPATHs introduced
+  with Java6.  Ant will not expand or evaluate the wildcards and the
+  resulting path may not work as anything else but a CLASSPATH - or
+  even as a CLASSPATH for a Java VM prior to Java6.</p>
 <p>As a shortcut, the <code>&lt;classpath&gt;</code> tag
 supports <code>path</code> and
 <code>location</code> attributes of its own, so:</p>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java?rev=955896&r1=955895&r2=955896&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java Fri Jun 18 09:03:34 2010
@@ -342,6 +342,12 @@ public class Path extends DataType imple
             }
             if (f.exists()) {
                 setLocation(f);
+            } else if (f.getParentFile() != null && f.getParentFile().exists()
+                       && containsWildcards(f.getName())) {
+                setLocation(f);
+                log("adding " + f + " which contains wildcards and may not"
+                    + " do what you intend it to do depending on your OS or"
+                    + " version of Java", Project.MSG_VERBOSE);
             } else {
                 log("dropping " + f + " from path as it doesn't exist",
                     Project.MSG_VERBOSE);
@@ -759,4 +765,14 @@ public class Path extends DataType imple
         }
         return preserveBC.booleanValue();
     }
+
+    /**
+     * Does the given file name contain wildcards?
+     * @since Ant 1.8.2
+     */
+    private static boolean containsWildcards(String path) {
+        return path != null
+            && (path.indexOf("*") > -1 || path.indexOf("?") > -1);
+    }
+
 }

Modified: ant/core/trunk/src/tests/antunit/types/path-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/types/path-test.xml?rev=955896&r1=955895&r2=955896&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/types/path-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/types/path-test.xml Fri Jun 18 09:03:34 2010
@@ -39,4 +39,13 @@
     </path>
   </target>
 
+  <target name="test-wildcard"
+          description="https://issues.apache.org/bugzilla/show_bug.cgi?id=46842">
+    <path id="with-wildcard">
+      <pathelement location="*"/>
+    </path>
+    <au:assertEquals expected="${basedir}${file.separator}*"
+                     actual="${toString:with-wildcard}"/>
+  </target>
+
 </project>



Mime
View raw message