Since Ant 1.9.1 it is possible to add if and unless attributes on all tasks and nested elements using special namespaces.
In order to use this feature you need to add the following namespace declarations
xmlns:if="ant:if" xmlns:unless="ant:unless"
The if and unless namespaces support the following 3 conditions :
<project name="tryit" xmlns:if="ant:if" xmlns:unless="ant:unless" > <exec executable="java"> <arg line="-X" if:true="${showextendedparams}"/> <arg line="-version" unless:true="${showextendedparams}"/> </exec> <condition property="onmac"> <os family="mac"/> </condition> <echo if:set="onmac">running on MacOS</echo> <echo unless:set="onmac">not running on MacOS</echo> </project>