Ant: target


if/unless 屬性

 <target name="dist" depends="local.dist" if="not.leaf">
    <iterate target="dist"/>
  </target>

如果if值爲一個屬性,那麼這個屬性not.leaf爲true、yes等"true-like"值時才運行這個target

1.8.0以後,if值可以不是屬性,只要他爲true就運行這個target,如:

<target name="-check-use-file" unless="file.exists">
    <available property="file.exists" file="some-file"/>
</target>
<target name="use-file" depends="-check-use-file" if="${file.exists}">
    <!-- do something requiring that file... -->
</target>
<target name="lots-of-stuff" depends="use-file,other-unconditional-stuff"/>

可運行 ant -Dfile.exists=false lots-of-stuff 來只運行 other-unconditional-stuff 而避免運行 use-file

對於unless,和if相反,值爲false時才運行target


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章