Conditions are nested elements of the
-<condition> and
-<waitfor> tasks.
- There are core conditions and custom conditions. Custom
- conditions are described in
-
- Custom Conditions.
- Core Conditions are described below.
-
The <not> element expects exactly one other
-condition to be nested into this element, negating the result of the
-condition. It doesn't have any attributes and accepts all nested
-elements of the condition task as nested elements as well.
-The <and> element doesn't have any attributes and
-accepts an arbitrary number of conditions as nested elements - all
-nested elements of the condition task are supported. This condition
-is true if all of its contained conditions are, conditions will be
-evaluated in the order they have been specified in the build file.
-
The <and> condition has the same shortcut
-semantics as the Java && operator, as soon as one of the
-nested conditions is false, no other condition will be evaluated.
-The <or> element doesn't have any attributes and
-accepts an arbitrary number of conditions as nested elements - all
-nested elements of the condition task are supported. This condition
-is true if at least one of its contained conditions is, conditions
-will be evaluated in the order they have been specified in the build
-file.
The <or> condition has the same
-shortcut semantics as the Java || operator, as soon as one of the
-nested conditions is true, no other condition will be evaluated.
The <xor> element performs an exclusive
-or on all nested elements, similar to the ^ operator
-in Java. It only evaluates to true if an odd number of nested conditions
-are true. There is no shortcutting of evaluation, unlike the <and>
-and <or> tests.
-It doesn't have any attributes and accepts all nested
-elements of the condition task as nested elements as well.
This condition is identical to the Available task, all attributes and nested
-elements of that task are supported, the property and value attributes
-are redundant and will be ignored.
This condition is identical to the Uptodate task, all attributes and nested
-elements of that task are supported, the property and value attributes
-are redundant and will be ignored.
Test whether the current operating system is of a given type. Each
-defined attribute is tested and the result is true only if all
-the tests succeed.
-
-
-
-
Attribute
-
Description
-
Required
-
-
-
family
-
The name of the operating system family to expect.
-
No
-
-
-
name
-
The name of the operating system to expect.
-
No
-
-
-
arch
-
The architecture of the operating system to expect.
-
No
-
-
-
version
-
The version of the operating system to expect.
-
No
-
-
-
Supported values for the family attribute are:
-
-
windows (for all versions of Microsoft Windows)
-
dos (for all Microsoft DOS based operating systems including
- Microsoft Windows and OS/2)
-
mac (for all Apple Macintosh systems)
-
unix (for all Unix and Unix-like operating systems)
-
netware (for Novell NetWare)
-
os/2 (for OS/2)
-
tandem (for HP's NonStop Kernel - formerly Tandem)
-
win9x for Microsoft Windows 95 and 98, ME and CE
-
winnt for Microsoft Windows NT-based systems, including Windows 2000, XP and
- successors
This condition is identical to the Checksum
-task, all attributes and nested elements of that task are supported,
-the property and overwrite attributes are redundant and will be
-ignored.
The http condition checks for a valid response from a
-web server of the specified url. By default, HTTP responses errors
-of 400 or greater are viewed as invalid.
-
-
-
Attribute
-
Description
-
Required
-
-
-
url
-
The full URL of the page to request. The web server must
- return a status code below the value of errorsBeginAt
-
Yes.
-
-
-
errorsBeginAt
-
The lowest HTTP response code that signals an error;
- by default '400'; server errors, not-authorized, not-found and the like
- are detected
-
No
-
-
-
requestMethod
-
The HTTP method to be used when issuing the request.
- Any of GET, POST, HEAD, OPTIONS, PUT, DELETEm and TRACE
- are valid, subject to protocol restrictions. The default if not
- specified is "GET".
- since Ant 1.8.0
Test two files for matching. Nonexistence of one file results in "false",
-although if neither exists they are considered equal in terms of content.
-This test does a byte for byte comparison, so test time scales with
-byte size. NB: if the files are different sizes, one of them is missing
-or the filenames match the answer is so obvious the detailed test is omitted.
-
-
-
-
-
Attribute
-
Description
-
Required
-
-
-
file1
-
First file to test
-
Yes
-
-
-
file2
-
Second file to test
-
Yes
-
-
-
textfile
-
Whether to ignore line endings when comparing
- files; defaults to false which triggers a binary
- comparison. Since Ant 1.7
-
- Test whether a jarfile is signed.
- If the name of the
- signature is passed, the file is checked for presence of that
- particular signature; otherwise the file is checked for the
- existence of any signature. It does not perform rigorous
- signature validation; it only looks for the presence of a signature.
-
-
- This condition was added in Apache Ant 1.7.
-
-
-
-
Attribute
-
Description
-
Required
-
-
-
file
-
- The jarfile that is to be tested for the presence
- of a signature.
-
Test whether a given type is defined, and that
-its implementation class can be loaded. Types include
-tasks, datatypes, scriptdefs, macrodefs and presetdefs.
Evaluate a condition based on a script in any
-Apache BSF
- or
- JSR 223
-supported language.
-
-
-See the Script task for
-an explanation of scripts and dependencies.
-
-
-
This condition was added in Apache Ant 1.7.
-
-
-
-
Attribute
-
Description
-
Required
-
-
-
language
-
script language
-
Yes
-
-
-
manager
-
- The script engine manager to use.
- See the script task
- for using this attribute.
-
-
No - default is "auto"
-
-
-
value
-
default boolean value
-
No -default is "false"
-
-
-
src
-
filename of script source
-
No
-
-
-
setbeans
-
whether to have all properties, references and targets as
- global variables in the script. since Ant 1.8.0
-
No, default is "true".
-
-
-
classpath
-
- The classpath to pass into the script.
-
-
No
-
-
-
classpathref
-
The classpath to use, given as a
- reference to a path defined elsewhere.
-
No
-
-
-
Parameters specified as nested elements
-
classpath
-
- See the script task
- for using this nested element.
-
-
Description
-
-The script supports script language inline, this script has access to the
-same beans as the <script> task, and to the self bean,
-which refers back to the condition itself. If the script evaluates to a boolean result,
-this is the result of the condition's evaluation (since Ant 1.7.1).
-Alternatively, self.value can be used to set the evaluation result.
-
Tests whether Ant's XML parser supports a given
-feature or property, as per the SAX/JAXP specifications, by
-attempting to set the appropriate property/feature/
Uses Java1.5+ networking APIs to probe for a (remote) system being
-reachable. Exactly what probe mechanisms are used is an implementation
-feature of the JVM. They may include ICMP "ping" packets, UDP or TCP connections
-to port 7 "echo service" or other means. On Java1.4 and earlier, being able
-to resolve the hostname is considered success. This means that if DNS is not
-working or a URL/hostname is bad, the test will fail, but otherwise succeed
-even if the remote host is actually absent.
-
-
-
-This condition turns unknown host exceptions into false conditions. This is
-because on a laptop, DNS is one of the first services when the network goes; you
-are implicitly offline.
-
-
- If a URL is supplied instead of a host, the hostname is extracted
- and used in the test - all other parts of the URL are discarded.
-
-
-The test may not work through firewalls, that is, something may be reachable
-using a protocol such as HTTP, while the lower level ICMP packets get dropped
-on the floor. Similarly, a host may detected as reachable with ICMP, but
-not reachable on other ports (i.e. port 80), because of firewalls.
-
Test resources for matching. Nonexistence of one or more resources results in
-"false", although if none exists they are considered equal in terms of content.
-By default this test does a byte for byte comparison, so test time scales with
-byte size. NB: if the files are different sizes, one of them is missing
-or the filenames match the answer is so obvious the detailed test is omitted.
-The resources to check are specified as nested
-resource collections,
-meaning that more than two resources can be checked; in this case all resources
-must match. Since Ant 1.7
-
-
-
-
Attribute
-
Description
-
Required
-
-
-
astext
-
Whether to ignore line endings
- when comparing resource content; defaults to false,
- while true triggers a binary comparison.
-
- Test if the specified string matches the specified regular
- expression pattern.
- Since Ant 1.7
-
-
-
-
Attribute
-
Description
-
Required
-
-
-
string
-
The string to test.
-
Yes
-
-
-
pattern
-
The regular expression pattern used to test.
-
Yes, unless there is a nested
- <regexp> element.
-
-
-
casesensitive
-
Perform a case sensitive match. Default is
- true.
-
No
-
-
-
multiline
-
- Perform a multi line match.
- Default is false.
-
No
-
-
-
singleline
-
- This allows '.' to match new lines.
- SingleLine is not to be confused with multiline, SingleLine is a perl
- regex term, it corresponds to dotall in java regex.
- Default is false.
-
No
-
-
-
-
- There is also an optional <regexp> element, which can be used to specify
- a regular expression instead of the "pattern" attribute.
- See Regexp Type for the description
- of the nested element regexp and of
- the choice of regular expression implementation.
-
-
- An example:
-
-
-<condition property="legal-password">
- <matches pattern="[1-9]" string="${user-input}"/>
-</condition>
-<fail message="Your password should at least contain one number"
- unless="legal-password"/>
-
-
- The following example sets the property "ok" if
- the property "input" is three characters long, starting
- with 'a' and ending with 'b'.
-
- The following defines a reference regular expression for
- matching dates and then uses antunit to check if the
- property "today" is in the correct format:
-