diff --git a/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java b/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java
index 7fbc79864..6549b06b9 100644
--- a/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java
+++ b/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java
@@ -133,4 +133,20 @@ public class RegexpMatcherFactory {
throw new BuildException(t);
}
}
+
+ /**
+ * Checks if a RegExp-Matcher is available.
+ * @param project The project to check for (may be null
)
+ * @return true
if available otherwise false
+ */
+ public static boolean regexpMatcherPresent(Project project) {
+ try {
+ // The factory throws a BuildException if no usable matcher
+ // cant be instantiated. We dont need the matcher itself here.
+ (new RegexpMatcherFactory()).newRegexpMatcher(project);
+ return true;
+ } catch (Throwable ex) {
+ return false;
+ }
+ }
}
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java
index b7b0c3048..104e370d4 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java
@@ -18,9 +18,12 @@
package org.apache.tools.ant.taskdefs;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileTest;
import org.apache.tools.ant.taskdefs.condition.Os;
import org.apache.tools.ant.util.JavaEnvUtils;
-import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.util.regexp.RegexpMatcher;
+import org.apache.tools.ant.util.regexp.RegexpMatcherFactory;
/**
* Tests <bm:manifestclasspath>.
@@ -97,8 +100,11 @@ public class ManifestClassPathTest
}
public void testPseudoTahoeRefid() {
+ if (!RegexpMatcherFactory.regexpMatcherPresent(project)) {
+ System.out.println("Test 'testPseudoTahoeRefid' skipped because no regexp matcher is present.");
+ return;
+ }
executeTarget("test-pseudo-tahoe-refid");
-
assertPropertyEquals("jar.classpath", "classes/dsp-core/ " +
"classes/dsp-pres/ " +
"classes/dsp-void/ " +
@@ -108,8 +114,11 @@ public class ManifestClassPathTest
}
public void testPseudoTahoeNested() {
+ if (!RegexpMatcherFactory.regexpMatcherPresent(project)) {
+ System.out.println("Test 'testPseudoTahoeNested' skipped because no regexp matcher is present.");
+ return;
+ }
executeTarget("test-pseudo-tahoe-nested");
-
assertPropertyEquals("jar.classpath", "classes/dsp-core/ " +
"classes/dsp-pres/ " +
"classes/dsp-void/ " +
@@ -134,8 +143,7 @@ public class ManifestClassPathTest
"../../resources/dsp-void/");
}
public void testInternationalGerman() {
- if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4))
- {
+ if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) {
System.out.println("Test with international characters skipped under pre 1.4 jvm.");
return;
}
@@ -144,7 +152,7 @@ public class ManifestClassPathTest
}
public void testInternationalHebrew() {
- if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) {
+ if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) {
System.out.println("Test with international characters skipped under pre 1.4 jvm.");
return;
}