diff --git a/WHATSNEW b/WHATSNEW index 6d9470ed9..3fd4c4eef 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -36,6 +36,9 @@ Fixed bugs: * documented minimal version of jsch now 0.1.29. Bugzilla report 40333. +* searched parent directories for files. + Bugzilla report 37148. + Other changes: -------------- diff --git a/docs/manual/CoreTasks/available.html b/docs/manual/CoreTasks/available.html index 161a64384..6e4a17185 100644 --- a/docs/manual/CoreTasks/available.html +++ b/docs/manual/CoreTasks/available.html @@ -96,10 +96,10 @@ execution depending on system parameters.

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 + will also search the parent directories of those specified. If false, only the directories specified will be searched. - Defaults to "true". + Defaults to "false". Since Ant 1.7 No diff --git a/src/etc/testcases/taskdefs/available.xml b/src/etc/testcases/taskdefs/available.xml index 8eed312f4..f445bd782 100644 --- a/src/etc/testcases/taskdefs/available.xml +++ b/src/etc/testcases/taskdefs/available.xml @@ -177,13 +177,15 @@ value="greatgrandparent/grandparent/parent/dir"/> - testing greatgrandparent - should not see + testing greatgrandparent - should see - - - + + + + + @@ -191,7 +193,7 @@ - + @@ -202,7 +204,7 @@ - + @@ -213,7 +215,7 @@ - + @@ -226,7 +228,7 @@ testing grandparent - should not see - + @@ -235,7 +237,7 @@ testing parent - should not see - + @@ -245,7 +247,7 @@ - + diff --git a/src/main/org/apache/tools/ant/taskdefs/Available.java b/src/main/org/apache/tools/ant/taskdefs/Available.java index 030760385..dab6b925a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Available.java +++ b/src/main/org/apache/tools/ant/taskdefs/Available.java @@ -53,14 +53,14 @@ public class Available extends Task implements Condition { private String value = "true"; private boolean isTask = false; private boolean ignoreSystemclasses = false; - private boolean searchParents = true; + private boolean searchParents = false; /** * 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. + * The default value is false. * @param searchParents the value to set. */ public void setSearchParents(boolean searchParents) { @@ -366,21 +366,12 @@ public class Available extends Task implements Condition { } } // ** simple name specified == parent dir + name - if (parent != null && parent.exists() && searchParents) { + while (searchParents && parent != null && parent.exists()) { if (checkFile(new File(parent, filename), filename + " in " + parent)) { return true; } - } - // ** simple name specified == parent of parent dir + name - if (parent != null && searchParents) { - File grandParent = parent.getParentFile(); - if (grandParent != null && grandParent.exists()) { - if (checkFile(new File(grandParent, filename), - filename + " in " + grandParent)) { - return true; - } - } + parent = parent.getParentFile(); } } }