## Condition

### Description

Sets a property if a certain condition holds true—this is a generalization of Available and Uptodate.

If the condition holds true, the property value is set to true by default; otherwise, the property is not set. You can set the value to something other than the default by specifying the value attribute.

Conditions are specified as nested elements, you must specify exactly one condition.

### Parameters

Attribute | Description | Required
--- | --- | ---
property | The name of the property to set. | Yes
value | The value to set the property to. | No; defaults to true
else | The value to set the property to if the condition evaluates to false. Since Apache Ant 1.6.3 | No; by default the property will remain unset

### Parameters specified as nested elements

All conditions to test are specified as nested elements, for a complete list see here.

### Examples

    <condition property="javamail.complete">
      <and>
        <available classname="javax.activation.DataHandler"/>
        <available classname="javax.mail.Transport"/>
      </and>
    </condition>

sets the property `javamail.complete` if both the JavaBeans Activation Framework and JavaMail are available in the classpath.

    <condition property="isMacOsButNotMacOsX">
      <and>
        <os family="mac"/>
        <not>
          <os family="unix"/>
        </not>
      </and>
    </condition>

sets the property `isMacOsButNotMacOsX` if the current operating system is MacOS, but not MacOS X/macOS—which Ant considers to be in the Unix family as well.

    <condition property="isSunOSonSparc">
      <os name="SunOS" arch="sparc"/>
    </condition>

sets the property `isSunOSonSparc` if the current operating system is SunOS and if it is running on a SPARC architecture.