[英]Ant resource exists check
我在使用ant测试文件是否存在问题。 我想检查目标test
是否存在文件,如果不存在,我想下载目标download
文件。 但是download
目标将始终执行(如果文件存在或不存在)。 有人可以证明出什么问题了吗?
<!-- Test lib files if exist -->
<target name="test">
<condition property="is.resource.exists" value="true" else="false">
<and>
<resourceexists>
<file file="${lib}/jdom-2.0.5.jar" />
</resourceexists>
<resourceexists>
<file file="${lib}/miglayout-4.0-swing.jar" />
</resourceexists>
</and>
</condition>
</target>
<!-- Download lib files if not exist -->
<target name="download" if="is.resource.exists" depends="test">
<exec dir="${lib}" executable="${lib}/get-libs.sh" />
</target>
甲<target>
与if
如果在属性属性将执行if
属性存在 。 类似地,如果unless
属性中的属性不存在,则将执行带有unless
属性的<target>
。 属性的值是什么无关紧要:真,假,金橘等。
替换if="is.resource.exists"
有unless="is.resource.exists"
,你应该是不错的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.