views:

23

answers:

1

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

+2  A: 

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