- ANT Tasks - Home
- ANT Tasks - Introduction
- ANT Tasks - Environment Setup
- Apache ANT Tasks Examples
- ANT Tasks - BaseName
- ANT Tasks - GZip
- ANT Tasks - GUnzip
- ANT Tasks - Chmod
- ANT Tasks - Concat
- ANT Tasks - Condition
- ANT Tasks - Copy
- ANT Tasks - Delete
- ANT Tasks - EAR
- ANT Tasks - Fail
- ANT Tasks - Import
- ANT Tasks - Java
- ANT Tasks - Javac
- ANT Tasks - Length
- ANT Tasks - LoadFile
- ANT Tasks - MkDir
- ANT Tasks - Move
- ANT Tasks - Sleep
- ANT Tasks - WAR
- ANT Tasks - Zip
- ANT Tasks -JAR
- Apache ANT Tasks Useful Resources
- Ant Tasks - Quick Guide
- Ant Tasks - Useful Resources
- Ant Tasks - Discussion
Apache Ant - Condition Task
Description
Condition task sets the property value to true by default if condition is true; otherwise, the property is not set. You can set the value to something other than the default by specifying the value attribute.
Properties
| Sr.No | Attributes & Description |
|---|---|
| 1 |
Property The name of the property to set. (Mandatory) |
| 2 |
Value The value to set the property to. |
| 3 |
Else The value to set the property to if the condition evaluates to false. |
Example
Usage
Create build.xml with the following content −
<?xml version="1.0"?>
<project name="TutorialPoint" default="info">
<condition property="isWindows">
<os family="windows"/>
</condition>
<target name="info">
<echo message="${isWindows}"></echo>
</target>
</project>
Above script will set a variable is Windows based on the underlying operation system is windows or not.
Output
Running Ant on the above build file produces the following output −
F:\tutorialspoint\ant>ant Buildfile: F:\tutorialspoint\ant\build.xml info: [echo] true BUILD SUCCESSFUL Total time: 0 seconds
Advertisements