开发者

ant conditional import

Is it possible to 开发者_JS百科import a file in ant's build.xml if a property is set, if not then don't import it.

Is there a way OTHER THAN using ant-contrib if task.

Thanks


Yes, you can. For example:

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

Available conditions are described in Apache Ant Manual.


This is quite an old question but since Ant 1.9.1 you can use the "if"-attribute to do conditional imports:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜