知乎专栏 |
<if> <available file="my_directory" type="dir" /> <then> <echo message="Directory exists" /> </then> <else> <echo message="Directory does not exist" /> </else> </if>
Ant 1.9.x 新增 xmlns:if="ant:if"
<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> <!DOCTYPE project> <project xmlns:if="ant:if" xmlns:unless="ant:unless"> <property unless:set="property" name="property.is.set" value="false"/> <property if:set="property" name="property.is.set" value="true"/> <echo>${property.is.set}</echo> </project>