if と unless

Ant 1.9.1 以降、特別な名前空間を使用してすべてのタスクとネストされたエレメントに ifunless 属性を追加できます。

この機能を使用するには、以下の名前空間宣言を追加する必要があります

xmlns:if="ant:if"
xmlns:unless="ant:unless"

ifunless 名前空間は次の 3 つの条件をサポートしています

true
属性の値が true に評価された場合に true
blank
属性の値が null または空の場合に true
set
指定されたプロパティが設定されている場合に true
<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>