使用ant在INI文件中设置查找参数

时间:2013-10-17 11:55:38

标签: ant

我有一个配置文件,称之为“config.ini”,我有类似的东西:

somevar1=11111
somevar2=11111
password=
somevar4=11111

如何在Ant中创建,知道我的构建脚本是否已设置密码参数(对任何东西)?

2 个答案:

答案 0 :(得分:1)

的build.xml

<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>

命令输出:ant -Dpassword = myPassw0rd

run:
     [echo] password.set: true

命令输出:ant -Dpassword =

run:
     [echo] password.set: false

答案 1 :(得分:0)

您可以使用property任务:

<property file="config.ini"/>

<condition property="password.set" else="false">
  <isset property="passowrd"/>
</condition>