Ant: target

来源:互联网 发布:儿童编程教育连锁机构 编辑:程序博客网 时间:2024/06/06 12:42


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


原创粉丝点击