git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@443456 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -36,6 +36,9 @@ Fixed bugs: | |||
| * documented minimal version of jsch now 0.1.29. | |||
| Bugzilla report 40333. | |||
| * <available> searched parent directories for files. | |||
| Bugzilla report 37148. | |||
| Other changes: | |||
| -------------- | |||
| @@ -96,10 +96,10 @@ execution depending on system parameters.</p> | |||
| <td valign="top">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". | |||
| <em>Since Ant 1.7</em> | |||
| </td> | |||
| <td align="center" valign="top">No</td> | |||
| @@ -177,13 +177,15 @@ | |||
| value="greatgrandparent/grandparent/parent/dir"/> | |||
| </target> | |||
| <target name="search-parents" depends="prep.parents"> | |||
| <echo>testing greatgrandparent - should not see</echo> | |||
| <echo>testing greatgrandparent - should see</echo> | |||
| <fail> | |||
| <condition> | |||
| <available file="a.txt"> | |||
| <filepath path="${available.test.dir}"/> | |||
| </available> | |||
| <not> | |||
| <available file="a.txt" searchparents="yes"> | |||
| <filepath path="${available.test.dir}"/> | |||
| </available> | |||
| </not> | |||
| </condition> | |||
| </fail> | |||
| @@ -191,7 +193,7 @@ | |||
| <fail> | |||
| <condition> | |||
| <not> | |||
| <available file="b.txt"> | |||
| <available file="b.txt" searchparents="yes"> | |||
| <filepath path="${available.test.dir}"/> | |||
| </available> | |||
| </not> | |||
| @@ -202,7 +204,7 @@ | |||
| <fail> | |||
| <condition> | |||
| <not> | |||
| <available file="c.txt"> | |||
| <available file="c.txt" searchparents="yes"> | |||
| <filepath path="${available.test.dir}"/> | |||
| </available> | |||
| </not> | |||
| @@ -213,7 +215,7 @@ | |||
| <fail> | |||
| <condition> | |||
| <not> | |||
| <available file="d.txt"> | |||
| <available file="d.txt" searchparents="yes"> | |||
| <filepath path="${available.test.dir}"/> | |||
| </available> | |||
| </not> | |||
| @@ -226,7 +228,7 @@ | |||
| <echo>testing grandparent - should not see</echo> | |||
| <fail> | |||
| <condition> | |||
| <available file="b.txt" searchParents="no"> | |||
| <available file="b.txt"> | |||
| <filepath path="${available.test.dir}"/> | |||
| </available> | |||
| </condition> | |||
| @@ -235,7 +237,7 @@ | |||
| <echo>testing parent - should not see</echo> | |||
| <fail> | |||
| <condition> | |||
| <available file="c.txt" searchParents="false"> | |||
| <available file="c.txt"> | |||
| <filepath path="${available.test.dir}"/> | |||
| </available> | |||
| </condition> | |||
| @@ -245,7 +247,7 @@ | |||
| <fail> | |||
| <condition> | |||
| <not> | |||
| <available file="d.txt" searchParents="false"> | |||
| <available file="d.txt"> | |||
| <filepath path="${available.test.dir}"/> | |||
| </available> | |||
| </not> | |||
| @@ -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(); | |||
| } | |||
| } | |||
| } | |||