When defining sequential build steps I use the depends
attribute of the target
element. I have recently seen an ant file, where the build sequence was defined by antcall
elements inside the targets.
To illustrate :
<target name="a" depends="b">
...</target>
vs
<target name="a">
<antcall target="b"/>
...</target>
Is there a real difference between the two approaches? Is one of them preferable?
The main difference between both approaches is that targets in depends
are always executed, while targets in antcall
are executed only if the containing target is.
A clarifying example:
<target name="a" depends="b" if="some.flag">
</target>
Here, b
will always be executed, while a
will be executed only if some.flag
is defined.
<target name="a" if="some.flag">
<antcall target="b" />
</target>
Here, b
will only be executed if a
is, i.e. if some.flag
is defined.