开发者

How can I execute an ant task more than once?

开发者 https://www.devze.com 2022-12-22 21:58 出处:网络
Imagine this as the code from build.xml: <project name=\"test project\"> <target name=\"first\">

Imagine this as the code from build.xml:

<project name="test project">
    <target name="first">
        <echo>first</echo>
    </target>
    <target name="second" depends="first">
        <echo>second</echo>
    </target>
    <target name="third" depends="first,second">
        <echo>third</echo>
    </target>
</project>

What do I need to do so that when I run:

ant third

I would receive开发者_如何学C the following output:

first,first,second,third

In other words, I would like each dependency to run regardless of whether it has ran before or not.


That's not what dependencies are for.

If you need that behavior, use antcall or MacroDef instead.

<project name="test project">
    <target name="first">
        <echo>first</echo>
    </target>
    <target name="second">
        <antcall target="first" />
        <echo>second</echo>
    </target>
    <target name="third">
        <antcall target="first" />
        <antcall target="second" />
        <echo>third</echo>
    </target>
</project>

> ant third
Buildfile: build.xml

third:

first:
     [echo] first

second:

first:
     [echo] first
     [echo] second
     [echo] third

BUILD SUCCESSFUL
Total time: 0 seconds
0

精彩评论

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