diff --git a/WHATSNEW b/WHATSNEW
index be5f05f0d..0b1e890fa 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -87,6 +87,14 @@ Other changes:
earlier -propertfiles or defined via the -D option).
Bugzilla Report 18732.
+ * 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
===================================
diff --git a/docs/manual/using.html b/docs/manual/using.html
index 4c12ff71d..76cd43fe4 100644
--- a/docs/manual/using.html
+++ b/docs/manual/using.html
@@ -262,6 +262,12 @@ or semicolon-separated lists of locations. The path
attribute is intended to be used with predefined paths - in any other
case, multiple elements with location
attributes should be
preferred.
+Since Ant 1.8.2 the location attribute can also contain a
+ wildcard in its last path component (i.e. it can end in a
+ "*") 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.
As a shortcut, the <classpath>
tag
supports path
and
location
attributes of its own, so:
diff --git a/src/main/org/apache/tools/ant/types/Path.java b/src/main/org/apache/tools/ant/types/Path.java
index dd60b8972..16443e6f5 100644
--- a/src/main/org/apache/tools/ant/types/Path.java
+++ b/src/main/org/apache/tools/ant/types/Path.java
@@ -342,6 +342,12 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
}
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 implements Cloneable, ResourceCollection {
}
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);
+ }
+
}
diff --git a/src/tests/antunit/types/path-test.xml b/src/tests/antunit/types/path-test.xml
index 61f5c3e73..4f4be9ab1 100644
--- a/src/tests/antunit/types/path-test.xml
+++ b/src/tests/antunit/types/path-test.xml
@@ -39,4 +39,13 @@
+
+
+
+
+
+
+