diff --git a/WHATSNEW b/WHATSNEW
index 2a8eda44f..2fb6fab0d 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -32,6 +32,7 @@ Other changes:
Bugzilla report 35619.
* Made PatterSet#hasPatterns public to allow custom filesets access.
Bugzilla report 36772.
+* added searchparents attribute to . Bugzilla report 39549.
Changes from Ant 1.6.5 to Ant 1.7.0Beta1
========================================
diff --git a/docs/manual/CoreTasks/available.html b/docs/manual/CoreTasks/available.html
index e7b7bbdd5..72b7a6ffa 100644
--- a/docs/manual/CoreTasks/available.html
+++ b/docs/manual/CoreTasks/available.html
@@ -75,7 +75,19 @@ execution depending on system parameters.
classpath. Only affects the "classname" attribute. Defaults to "false"
No |
-
+
+ searchparents |
+ This contains the behaviour of the "file" type.
+ If true, the available task will, when
+ searching for a file, search not only the directories specified but
+ will also search the parent and grandparent directories of those
+ specified.
+ If false, only the directories specified will be searched.
+ Defaults to "true".
+ Since Ant 1.7
+ |
+ No |
+
Parameters specified as nested elements
classpath
diff --git a/src/etc/testcases/taskdefs/available.xml b/src/etc/testcases/taskdefs/available.xml
index ca2b3cbd8..8eed312f4 100644
--- a/src/etc/testcases/taskdefs/available.xml
+++ b/src/etc/testcases/taskdefs/available.xml
@@ -2,6 +2,10 @@
+
+
+
+
@@ -162,4 +166,91 @@
+
+
+
+
+
+
+
+
+
+
+ testing greatgrandparent - should not see
+
+
+
+
+
+
+
+
+
+ testing grandparent - should see
+
+
+
+
+
+
+
+
+
+
+ testing parent - should see
+
+
+
+
+
+
+
+
+
+
+ testing dir - should see
+
+
+
+
+
+
+
+
+
+
+
+
+
+ testing grandparent - should not see
+
+
+
+
+
+
+
+
+ testing parent - should not see
+
+
+
+
+
+
+
+
+ testing dir - should see
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/Available.java b/src/main/org/apache/tools/ant/taskdefs/Available.java
index 9628bc50d..030760385 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Available.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Available.java
@@ -53,6 +53,19 @@ public class Available extends Task implements Condition {
private String value = "true";
private boolean isTask = false;
private boolean ignoreSystemclasses = false;
+ private boolean searchParents = true;
+
+ /**
+ * Set the searchParents attribute.
+ * This controls the behaviour of the the "file" type.
+ * If true, the path, parent path and grandparent path are
+ * searched for the file. If false, only the path is seached.
+ * The default value is true.
+ * @param searchParents the value to set.
+ */
+ public void setSearchParents(boolean searchParents) {
+ this.searchParents = searchParents;
+ }
/**
* Set the classpath to be used when searching for classes and resources.
@@ -353,14 +366,14 @@ public class Available extends Task implements Condition {
}
}
// ** simple name specified == parent dir + name
- if (parent != null && parent.exists()) {
+ if (parent != null && parent.exists() && searchParents) {
if (checkFile(new File(parent, filename),
filename + " in " + parent)) {
return true;
}
}
// ** simple name specified == parent of parent dir + name
- if (parent != null) {
+ if (parent != null && searchParents) {
File grandParent = parent.getParentFile();
if (grandParent != null && grandParent.exists()) {
if (checkFile(new File(grandParent, filename),
diff --git a/src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java b/src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java
index 980b4138b..57b9ff024 100644
--- a/src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java
+++ b/src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java
@@ -201,4 +201,13 @@ public class AvailableTest extends BuildFileTest {
public void testDoubleBasedir() {
executeTarget("testDoubleBasedir");
}
+
+ // test for searching parents
+ public void testSearchParents() {
+ executeTarget("search-parents");
+ }
+ // test for not searching parents
+ public void testSearchParentsNot() {
+ executeTarget("search-parents-not");
+ }
}