2

我有一个任务:

<target name="someTarget">
    <concat destfile="someFile">
        <string>someString</string>

        <string>someOtherString</string>
    </concat>
</target>

<target name="someOtherTarget">
    <antcall target="someTarget">
        <param name="myParam" value="myValue"></param>
    </antcall>

    <antcall target="someTarget">
    </antcall>
</target>

如何连接调用目标时提供的someOtherString唯一 if ?myParamsomeTarget

4

1 回答 1

4

如果没有 Ant 扩展,只需使用条件 Ant 执行

<project default="someOtherTarget">
    <target name="someTarget" depends="-someString,-someOtherString"/>

    <target name="-someString" unless="myParam">
        <concat destfile="someFile">
            <string>someString</string>
        </concat>
    </target>

    <target name="-someOtherString" if="myParam">
        <concat destfile="someOtherFile">
            <string>someString</string>
            <string>someOtherString</string>
        </concat>
    </target>

    <target name="someOtherTarget">
        <antcall target="someTarget">
            <param name="myParam" value="myValue"></param>
        </antcall>
        <antcall target="someTarget"/>
    </target>
</project>

如果您不介意将 Ant 扩展添加到您的项目中,请查看Ant-ContribIf 任务

于 2012-06-10T14:58:08.397 回答