[英]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.