## Conditions

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.

### Core Conditions

These are the nested elements that can be used as conditions in the `<condition>` and `<waitfor>` tasks.

#### not

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.

#### and

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.

#### or

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.

#### available

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.

#### uptodate

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.

#### os

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
- z/os for z/OS and OS/390
- os/400 for OS/400
- openvms for OpenVMS

#### equals

Tests whether the two given Strings are identical

Attribute | Description | Required
arg1 | First string to test. | Yes
arg2 | Second string to test. | Yes
casesensitive | Perform a case sensitive comparision. Default is true. | No
trim | Trim whitespace from arguments before comparing them. Default is false. | No

#### isset

Test whether a given property has been set in this project.

Attribute | Description | Required
property | The name of the property to test. | Yes

#### checksum

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.

#### http

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

#### socket

The `socket` condition checks for the existence of a TCP/IP listener at the specified host and port.

Attribute | Description | Required
server | The DNS name or IP address of the server. | Yes.
port | The port number to connect to. | Yes.

#### filesmatch

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.

Attribute | Description | Required
file1 | First file to test | Yes.
file2 | Second file to test | Yes.

#### contains

Tests whether a string contains another one.

Attribute | Description | Required
string | The string to search in. | Yes
substring | The string to search for. | Yes
casesensitive | Perform a case sensitive comparision. Default is true. | No

#### istrue

Tests whether a string equals any of the ant definitions of true, that is "true","yes", or "on"

Attribute | Description | Required
value | value to test | Yes

        <istrue value="${someproperty}"/>
        <istrue value="false"/>

#### isfalse

Tests whether a string is not true, the negation of <istrue>

Attribute | Description | Required
value | value to test | Yes

        <isfalse value="${someproperty}"/>
        <isfalse value="false"/>

#### isreference

Test whether a given reference has been defined in this project and - optionally - is of an expected type.

This condition has been added in Apache Ant 1.6.

Attribute | Description | Required
refid | The id of the reference to test. | Yes
type | Name of the data type or task this reference is expected to be. | No

Copyright © 2001-2003 Apache Software Foundation. All rights Reserved.