我有一个配置文件,称之为“config.ini”,我有类似的东西:
somevar1=11111
somevar2=11111
password=
somevar4=11111
如何在Ant中创建,知道我的构建脚本是否已设置密码参数(对任何东西)?
答案 0 :(得分:1)
<project name="ant-length-of-property" default="run">
<target name="run">
<condition property="password.set" else="false">
<and>
<isset property="password"/>
<length string="${password}" when="greater" length="0"/>
</and>
</condition>
<echo>password.set: ${password.set}</echo>
</target>
</project>
run:
[echo] password.set: true
run:
[echo] password.set: false
答案 1 :(得分:0)
您可以使用property
任务:
<property file="config.ini"/>
<condition property="password.set" else="false">
<isset property="passowrd"/>
</condition>