Developing Web Applications With Ant by Richard Hightower - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Conditional Targets

Targets can be conditionally executed, depending on whether you set a property. For example, to optionally execute a target if the production property is set, you define a target as follows:

<target name="setupProduction" if="production">
<property name="lib" value="/usr/home/production/lib"/>
<property name="outputdir" value="/usr/home/production/classes"/>

</target>

 

To define a target that executes only if the production target is not set, use this:

<target name="setupDevelopment" unless="production">
<property name="lib" value="c:/hello/lib"/>
<property name="outputdir" value="c:/hello/classes"/>

</target>

 

Conditional execution of targets is another way to support multiple deployment environments.