Apache Ant

Ant if and unless both are the attributes of <target> element (tasks). These attributes are used to control tasks whether task is run or not.

  1. Apache Antiques
  2. Apache Ant Tasks
  3. Apache Ant Documentation
  4. Download Apache Ant For Windows
  5. Apache Ant Environment Variables
  6. Apache Ant Download 1.6.2

Apache Antiques

Apache Ant

Step 2: Download zip file named like apache-ant-1.10.1-bin.zip Step 3: Extract the zip file into a directory structure of your choice. Step 4: Go to Computer – Properties – Advanced system settings. Apache Ant is an open-source library which allows users to access the source code and reproduce it. Apache Ant is a cross-platform tool which allows you to handle Java classpath and file directory structure in an affordable manner. Apache Ant is easily extensible using Java and other programming languages.

Apart from target, it can also be used with <target> and <junit> elements.

In earlier versions and Ant 1.7.1, these attributes are only property names. If the property is defined, it runs even the value is false.

For example there is no way to stop execution even after passing false.

Apache ant commands

// build.xml

Output:

No Arguments: Run it by without command line arguments. Just enter ant to the terminal, but first locate to the project location and it will show empty output.

With Argument: Now pass argument butfalse.

Apache Ant Tasks

Ant -0Dfile.exists=false


Now pass argument but true.
Ant -Dfile.exists=true

Apache Ant

Since Ant 1.8.0, we can use property expansion that allows to execute only if value is true. In new version, it gives us more flexibility and now we can override the condition value from the command line. See an example below.

// build.xml

Output:

Apache Ant Documentation

No Arguments: Run it without command line arguments. Just enter ant to the terminal, but first locate to the project's location and it will show the empty output.

With Argument: Now pass argument but false.
Ant -Dfile.exists=false

Download Apache Ant For Windows

No output, because this time if is not executed.

Apache Ant Environment Variables

With Argument: Now pass argument but true. Now it shows output because if is evaluated.
Ant -Dfile.exists=true

Apache Ant Download 1.6.2