Question

If I have three targets, one "all", one "compile" and one "jsps", how would I make "all" depend on the other two

Would it be

<target name="all" depends="compile,jsps">

or would it be

<target name="all" depends="compile","jsps">

Or maybe something even different?

I tried searching for example ant scripts to base it off of, but I couldn't find one with multiple depends.

Was it helpful?

Solution

The former:

<target name="all" depends="compile,jsps">

This is documented in the Ant Manual.

OTHER TIPS

It's the top one.

Just use the echo tag if you want to quickly see for yourself

<target name="compile"><echo>compile</echo></target>

<target name="jsps"><echo>jsps</echo></target>

<target name="all" depends="compile,jsps"></target>

You can also look at the antcall tag if you want more flexibility on ordering tasks

<target name="all" depends="compile,jsps">

This is documented in the Ant Manual.

An alternate way is to use antcall which is more flexible if you want to run the depending targets in parallel. Assuming compile and jsps can be run in parallel (i.e in any order), all target can be written as:

<target name="all" description="all target, parallel">
  <parallel threadCount="2">
    <antcall target="compile"/>
    <antcall target="jsps"/>
  </parallel>
</target>

Note that if targets can not be run in parallel, it is preferable to use the first flavor with depend attribute because antcalls are resolved only when executed and if the called target does not exists, the build will fail only at that point.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top