|
- <html>
-
- <head>
- <meta http-equiv="Content-Language" content="en-us">
- <title>Conditions Task</title>
- </head>
-
- <body>
-
- <h2><a name="Conditions">Conditions</a></h2>
- <p>Conditions are nested elements of the
- <a href="condition.html"><code><condition></code></a> and
- <a href="waitfor.html"><code><waitfor></code></a> tasks.
- There are core conditions and custom conditions. Custom
- conditions are described in
- <a href="../CoreTypes/custom-programming.html#customconditions">
- Custom Conditions</a>.
- Core Conditions are described below.
- </p>
- <h3><a name="coreconditions">Core Conditions</a></h3>
-
- <p>These are the nested elements that can be used as conditions in the
- <a href="condition.html"><code><condition></code></a> and
- <a href="waitfor.html"><code><waitfor></code></a> tasks.</p>
-
- <h4>not</h4>
- <p>The <code><not></code> 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.</p>
-
- <h4>and</h4> <p>
- The <code><and></code> 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.</p>
- <p>The <code><and></code> 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.</p>
-
- <h4>or</h4> <p>
- The <code><or></code> 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.</p> <p>The <code><or></code> 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.</p>
-
- <h4>xor</h4>
- <p>The <code><xor></code> element performs an exclusive
- or on all nested elements, similar to the <code>^</code> 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 <code><and></code>
- and <code><or></code> tests.
- It doesn't have any attributes and accepts all nested
- elements of the condition task as nested elements as well.</p>
-
- <h4>available</h4>
- <p>This condition is identical to the <a
- href="available.html">Available</a> task, all attributes and nested
- elements of that task are supported, the property and value attributes
- are redundant and will be ignored.</p>
-
- <h4>uptodate</h4>
- <p>This condition is identical to the <a
- href="uptodate.html">Uptodate</a> task, all attributes and nested
- elements of that task are supported, the property and value attributes
- are redundant and will be ignored.</p>
-
- <h4>os</h4>
- <p>Test whether the current operating system is of a given type. Each
- defined attribute is tested and the result is true only if <i>all</i>
- the tests succeed.
- </p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">family</td>
- <td valign="top">The name of the operating system family to expect.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">name</td>
- <td valign="top">The name of the operating system to expect.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">arch</td>
- <td valign="top">The architecture of the operating system to expect.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">version</td>
- <td valign="top">The version of the operating system to expect.</td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
- <p>Supported values for the family attribute are:
- <ul>
- <li>windows (for all versions of Microsoft Windows)</li>
- <li>dos (for all Microsoft DOS based operating systems including
- Microsoft Windows and OS/2)</li>
- <li>mac (for all Apple Macintosh systems)</li>
- <li>unix (for all Unix and Unix-like operating systems)</li>
- <li>netware (for Novell NetWare)</li>
- <li>os/2 (for OS/2)</li>
- <li>tandem (for HP's NonStop Kernel - formerly Tandem)</li>
- <li>win9x for Microsoft Windows 95 and 98</li>
- <li>z/os for z/OS and OS/390</li>
- <li>os/400 for OS/400</li>
- <li>openvms for OpenVMS</li>
- </ul>
-
- <h4>equals</h4>
- <p>Tests whether the two given Strings are identical</p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">arg1</td>
- <td valign="top">First string to test.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">arg2</td>
- <td valign="top">Second string to test.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">casesensitive</td>
- <td valign="top">Perform a case sensitive comparision. Default is
- true.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">trim</td>
- <td valign="top">Trim whitespace from arguments before comparing
- them. Default is false.</td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
-
- <h4>isset</h4>
- <p>Test whether a given property has been set in this project.</p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">property</td>
- <td valign="top">The name of the property to test.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- </table>
-
- <h4>checksum</h4>
- <p>This condition is identical to the <a href="checksum.html">Checksum</a>
- task, all attributes and nested elements of that task are supported,
- the property and overwrite attributes are redundant and will be
- ignored.</p>
-
- <h4>http</h4>
- <p>The <code>http</code> 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.</p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td width="12%" valign="top"><b>Attribute</b></td>
- <td width="78%" valign="top"><b>Description</b></td>
- <td width="10%" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">url</td>
- <td valign="top">The full URL of the page to request. The web server must
- return a status code below the value of <tt>errorsBeginAt</tt></td>
- <td align="center">Yes.</td>
- </tr>
- <tr>
- <td valign="top">errorsBeginAt</td>
- <td valign="top">The lowest HTTP response code that signals an error;
- by default '400'; server errors, not-authorized, not-found and the like
- are detected</td>
- <td align="center">No</td>
- </tr>
- </table>
-
- <h4>socket</h4>
- <p>The <code>socket</code> condition checks for the existence of a
- TCP/IP listener at the specified host and port.</p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td width="12%" valign="top"><b>Attribute</b></td>
- <td width="78%" valign="top"><b>Description</b></td>
- <td width="10%" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">server</td>
- <td valign="top">The DNS name or IP address of the server.</td>
- <td align="center">Yes.</td>
- </tr>
- <tr>
- <td valign="top">port</td>
- <td valign="top">The port number to connect to.</td>
- <td align="center">Yes.</td>
- </tr>
- </table>
-
- <h4>filesmatch</h4>
- <p>Test two files for matching. Nonexistence of either file results in "false".
- This test does a byte for byte comparision, 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.
-
-
- </p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td width="12%" valign="top"><b>Attribute</b></td>
- <td width="78%" valign="top"><b>Description</b></td>
- <td width="10%" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">file1</td>
- <td valign="top">First file to test</td>
- <td align="center">Yes.</td>
- </tr>
- <tr>
- <td valign="top">file2</td>
- <td valign="top">Second file to test</td>
- <td align="center">Yes.</td>
- </tr>
- </table>
-
- <h4>contains</h4>
- <p>Tests whether a string contains another one.</p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">string</td>
- <td valign="top">The string to search in.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">substring</td>
- <td valign="top">The string to search for.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">casesensitive</td>
- <td valign="top">Perform a case sensitive comparision. Default is
- true.</td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
-
- <h4>istrue</h4>
- <p>Tests whether a string equals any of the ant definitions of true,
- that is "true","yes", or "on"</p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">value</td>
- <td valign="top">value to test</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- </table>
- <pre>
- <istrue value="${someproperty}"/>
- <istrue value="false"/>
- </pre>
-
- <h4>isfalse</h4>
- <p>Tests whether a string is not true, the negation of <istrue>
- </p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">value</td>
- <td valign="top">value to test</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- </table>
- <pre>
- <isfalse value="${someproperty}"/>
- <isfalse value="false"/>
- </pre>
-
- <h4>isreference</h4>
-
- <p>Test whether a given reference has been defined in this project and
- - optionally - is of an expected type.</p>
-
- <p>This condition has been added in Apache Ant 1.6.</p>
-
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">refid</td>
- <td valign="top">The id of the reference to test.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">type</td>
- <td valign="top">Name of the data type or task this reference is
- expected to be.</td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
- <h4>issigned</h4>
- <p>
- 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
- </p>
- <p>
- This condition was added in Apache Ant 1.7.
- </p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">file</td>
- <td valign="top">
- The jarfile that is to be tested for the presence
- of a signature.
- </td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">name</td>
- <td valign="top"> The signature name to check for.</td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
- <h4>isfileselected</h4>
- <p>
- Test whether a file passes an embedded selector.
- </p>
- <p>
- This condition was added in Apache Ant 1.7.
- </p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">file</td>
- <td valign="top">
- The file to check if is passes the embedded selector.
- </td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">basedir</td>
- <td valign="top">The base directory to use for name based selectors. It this is not set,
- the project's basedirectory will be used.</td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
- <p>
- Example usage:
- </p>
- <blockquote>
- <pre>
- <isfileselected file="a.xml">
- <date datetime="06/28/2000 2:02 pm" when="equal"/>
- </isfileselected>
- </pre></blockquote>
- <h4>typefound</h4>
-
- <p>Test whether a given type is defined, and that
- its implementation class can be loaded. Types include
- tasks, datatypes, scriptdefs, macrodefs and presetdefs.</p>
-
- <p>This condition was added in Apache Ant 1.7.</p>
-
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">name</td>
- <td valign="top">name of the type</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- </table>
-
- <h4>scriptcondition</h4>
-
- <p>Evaluate a condition based on a script in any
- <a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a>
- supported language.</p>
- <p>
- See the <a href="../OptionalTasks/script.html">Script</a> task for
- an explanation of scripts and dependencies.
- </p>
-
- <p>This condition was added in Apache Ant 1.7.</p>
-
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">language</td>
- <td valign="top">script language</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">value</td>
- <td valign="top">default boolean value</td>
- <td valign="top" align="center">No -default is "false"</td>
- </tr>
- <tr>
- <td valign="top">src</td>
- <td valign="top">filename of script source</td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
- <p>
- The script supports script language inline, this script has access to the
- same beans as the <code><script></code> task, and to the <code>
- self</code> bean, which refers back to the condition itself. The
- <code>value</code> property of this bean sets the return value:
- </p>
- <p>
- Example:
- </p>
- <pre>
- <scriptcondition language="javascript"
- value="true">
- self.setValue(false);
- </scriptcondition>
- </pre>
-
- Sets the default value of the condition to true, then in the script,
- sets the value to false. This condition always evaluates to "false"
- <hr>
- <p align="center">Copyright © 2001-2005 Apache Software
- Foundation. All rights Reserved.</p>
-
- </body>
- </html>
|