diff --git a/docs/manual/CoreTasks/fail.html b/docs/manual/CoreTasks/fail.html
index 0eb17416f..d0fe1a4ee 100644
--- a/docs/manual/CoreTasks/fail.html
+++ b/docs/manual/CoreTasks/fail.html
@@ -44,14 +44,14 @@ or character data nested into the element.
if |
- Only fail if a property of the given name exists
+ | Only fail if a property of the given name exists
in the current project |
No |
unless |
- Only fail if a property of the given name doesn't
- exist in the current project |
+ Only fail if a property of the given name doesn't
+ exist in the current project |
No |
diff --git a/docs/manual/CoreTasks/style.html b/docs/manual/CoreTasks/style.html
index ab8f58802..36f1f5f47 100644
--- a/docs/manual/CoreTasks/style.html
+++ b/docs/manual/CoreTasks/style.html
@@ -301,12 +301,12 @@ element is used to perform Entity and URI resolution.
if |
- The param will only passed if this property is set. |
+ The param will only be passed if this property is set. |
No |
unless |
- The param will only passed unless this property is set. |
+ The param will not be passed if this property is set. |
No |
diff --git a/docs/manual/CoreTypes/patternset.html b/docs/manual/CoreTypes/patternset.html
index 6d92caf27..f8195b404 100644
--- a/docs/manual/CoreTypes/patternset.html
+++ b/docs/manual/CoreTypes/patternset.html
@@ -82,13 +82,13 @@ exclude.
if |
- Only use this pattern if the named property is set. |
+ Only use this pattern if the named property is set. |
No |
unless |
- Only use this pattern if the named property is
- not set. |
+ Only use this pattern if the named property is
+ not set. |
No |
@@ -113,13 +113,13 @@ you can use to test the existance of a property.
if |
- Only read this file if the named property is set. |
+ Only read this file if the named property is set. |
No |
unless |
- Only read this file if the named property is
- not set. |
+ Only read this file if the named property is
+ not set. |
No |
diff --git a/docs/manual/CoreTypes/selectors.html b/docs/manual/CoreTypes/selectors.html
index 5f3efa12c..d63c29ecb 100644
--- a/docs/manual/CoreTypes/selectors.html
+++ b/docs/manual/CoreTypes/selectors.html
@@ -1380,15 +1380,15 @@ Select files whose filename length is even.
if |
- Allow files to be selected only if the named
- property is set.
+ | Allow files to be selected only if the named
+ property is set.
|
No |
unless |
- Allow files to be selected only if the named
- property is not set.
+ | Allow files to be selected only if the named
+ property is not set.
|
No |
diff --git a/docs/manual/OptionalTasks/junit.html b/docs/manual/OptionalTasks/junit.html
index ec648ebab..a89b92b37 100644
--- a/docs/manual/OptionalTasks/junit.html
+++ b/docs/manual/OptionalTasks/junit.html
@@ -414,12 +414,12 @@ time.
if |
- Only use formatter if the named property is set. |
+ Only use formatter if the named property is set. |
No; default is true . |
unless |
- Only use formatter if the named property is not set. |
+ Only use formatter if the named property is not set. |
No; default is true . |
@@ -493,12 +493,12 @@ time.
if |
- Only run test if the named property is set. |
+ Only run test if the named property is set. |
No |
unless |
- Only run test if the named property is not set. |
+ Only run test if the named property is not set. |
No |
@@ -571,12 +571,12 @@ supported.
if |
- Only run tests if the named property is set. |
+ Only run tests if the named property is set. |
No |
unless |
- Only run tests if the named property is not set. |
+ Only run tests if the named property is not set. |
No |
diff --git a/docs/manual/OptionalTasks/junitreport.html b/docs/manual/OptionalTasks/junitreport.html
index fa86d7d01..aaefbde56 100644
--- a/docs/manual/OptionalTasks/junitreport.html
+++ b/docs/manual/OptionalTasks/junitreport.html
@@ -143,12 +143,12 @@ These tags can pass XSL parameters to the stylesheet.
if |
- The param will only passed if this property is set. |
+ The param will only be passed if this property is set. |
No |
unless |
- The param will only passed unless this property is set. |
+ The param will not be passed if this property is set. |
No |
diff --git a/docs/manual/properties.html b/docs/manual/properties.html
index 2d959d444..e4f5b1a46 100644
--- a/docs/manual/properties.html
+++ b/docs/manual/properties.html
@@ -61,7 +61,7 @@
In addition, Ant has some built-in properties:
-
+
basedir the absolute path of the project's basedir (as set
with the basedir attribute of <project>).
ant.file the absolute path of the buildfile.
@@ -194,7 +194,8 @@ public class ToStringEvaluator implements PropertyHelper.PropertyEvaluator {
public Object evaluate(String property, PropertyHelper propertyHelper) {
Object o = null;
if (property.startsWith(prefix) && propertyHelper.getProject() != null) {
- o = propertyHelper.getProject().getReference(property.substring(prefix.length()));
+ o = propertyHelper.getProject().getReference(
+ property.substring(prefix.length()));
}
return o == null ? null : o.toString();
}
@@ -323,4 +324,73 @@ public void setAttr(Resource r) { ... }
<my:task attr="${ant.refid:anturl}"/>
+
+
+ The <target>
element and various tasks (such as
+ <exit>
) and task elements (such as <test>
+ in <junit>
) support if
and unless
+ attributes which can be used to control whether the item is run or otherwise
+ takes effect.
+
+
+ In Ant 1.7.1 and earlier, these attributes could only be property names.
+ The item was enabled if a property with that name was defined - even to be
+ the empty string or false - and disabled if the property was not
+ defined. For example, the following works but there is no way to override
+ the file existence check negatively (only positively):
+
+
+<target name="-check-use-file">
+ <available property="file.exists" file="some-file"/>
+</target>
+<target name="use-file" depends="-check-use-file" if="file.exists">
+ <!-- do something requiring that file... -->
+</target>
+<target name="lots-of-stuff" depends="use-file,other-unconditional-stuff"/>
+
+
+ As of Ant 1.8.0, you may instead use property expansion; a value of
+ true (or on or yes) will enable the
+ item, while false (or off or no) will
+ disable it. Other values are still assumed to be property
+ names and so the item is enabled only if the named property is defined.
+
+
+ Compared to the older style, this gives you additional flexibility, because
+ you can override the condition from the command line or parent scripts:
+
+
+<target name="-check-use-file" unless="file.exists">
+ <available property="file.exists" file="some-file"/>
+</target>
+<target name="use-file" depends="-check-use-file" if="${file.exists}">
+ <!-- do something requiring that file... -->
+</target>
+<target name="lots-of-stuff" depends="use-file,other-unconditional-stuff"/>
+
+
+ Now ant -Dfile.exists=false lots-of-stuff
will run
+ other-unconditional-stuff
but not use-file
,
+ as you might expect, and you can disable the condition from another script
+ too:
+
+
+<antcall target="lots-of-stuff">
+ <param name="file.exists" value="false"/>
+</antcall>
+
+
+ Similarly, an unless
attribute disables the item if it is
+ either the name of property which is defined, or if it evaluates to a
+ true-like value. For example, the following allows you to define
+ skip.printing.message=true in my-prefs.properties with
+ the results you might expect:
+
+
+<property file="my-prefs.properties"/>
+<target name="print-message" unless="${skip.printing.message}">
+ <echo>hello!</echo>
+</target>
+
+