Multiple depends in Ant task
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.
The former:
<target name="all" depends="compile,jsps">
This is documented in the Ant Manual.
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.
精彩评论