蚂蚁条件导入

时间:2010-06-22 15:41:49

标签: ant

如果设置了属性,是否可以在ant的build.xml中导入文件,如果没有则不导入它。

除了任务之外,还有其他方式使用ant-contrib吗?

由于

2 个答案:

答案 0 :(得分:2)

是的,你可以。 例如:

<target name="importFile" depends="myProperty.check" if="myPropertyIsSet">
    <echo>Import my file here</echo>
</target>

<target name="myTarget.check">
    <condition property="myPropertyIsSet">
        <and>
            <!-- Conditions to check if my property is set. -->
        </and>
    </condition>
</target>

可用条件在Apache Ant Manual中描述。

答案 1 :(得分:0)

这是一个很老的问题,但是从 Ant 1.9.1 开始,您可以使用“if”属性来进行条件导入:

<project name="cond-import" basedir="." xmlns:if="ant:if">
  <condition property="script-exists">
    <available file="other-ant-script.xml"/>
  </condition>
  <include if:set="script-exists" file="other-ant-script.xml"/>
</project>
相关问题