fi...">

How to execute ant task more than once?

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 I need to do so that at startup:

ant third

I would get the following output:

first,first,second,third

In other words, I would like each dependency to be executed regardless of whether it was executed earlier or not.

+3
source share
1 answer

No dependencies are needed for this.

If you need this behavior, use antcallor MacroDef.

<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
+4
source

Source: https://habr.com/ru/post/1736185/


All Articles