Ant 判断某个变量是否被赋值,某个文件|路径(文件夹)是否存在

来源:互联网 发布:枪与玫瑰乐队知乎 编辑:程序博客网 时间:2024/04/27 21:17

判断某个变量是否被赋值<isset>

<if>    <not>        <isset property="BonitaBPMCommunity.host" />    </not>    <then>        <property name="BonitaBPMCommunity.host" value="localhost"/>    </then></if>

判断某个文件是否存在<available ... type="file">

<available property="isExist" file="Git.xml" type="file" /><if>    <equals arg1="${isExist}" arg2="true" />    <then>        <echo>git.xml existed</echo>    </then></if>

也可以把<available>内嵌在<if>里。

<if>    <available file="Git.xml" type="file" />    <then>        <echo>git.xml existed</echo>    </then></if>

判断某个路径/文件夹是否存在<available ... type="dir">

跟判断文件的方法差不多,只不过type指定为dir。

另外如果type没有指定,不管找到的是file还是文件夹,都视为true.

0 0