Apache Ant target execute based on condition

To execute an Ant target based on condition, use the “if” attribute of the target,

<target name="build-module-A" if="module-A-present"/>

if the module-A-present property is set (to any value, e.g. false), the target will be run.


<target name="use-file" depends="-check-use-file" if="${file.exists}">

As of Ant 1.8.0, you may instead use property expansion; a value of true (or on or yes) will enable the item, while false (or off or no) will disable it. Other values are still assumed to be property names and so the item is enabled only if the named property is defined.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: