A target can depend
on other targets. You might have a target
for installing the files in the build tree, for example, and a target for creating a
distributable tar.gz archive. You can only build a distributable when you have
installed the files first, so the distribute target depends on the install target.
Phing resolves these dependencies.
It should be noted, however, that Phing's depends attribute only specifies the order in which targets should be executed - it does not affect whether the target that specifies the dependency(s) gets executed if the dependent target(s) did not (need to) run.
Phing tries to execute the targets in the depends attribute in the order they appear (from left to right). Keep in mind that it is possible that a target can get executed earlier when an earlier target depends on it, in this case the dependant is only executed once:
<target name="A" /> <target name="B" depends="A" /> <target name="C" depends="B" /> <target name="D" depends="C,B,A" />
Suppose we want to execute target D
. From its depends
aliteralribute, you might think that first target C
, then
B
and then A
is executed. Wrong!
C
depends on B
, and B
depends on A
, so first A
is executed, then
B
, then C
, and finally
D
.
A target gets executed only once, even when more than one target depends on it (see the previous example).
The optional description attribute can be used to provide a one-line description
of this target, which is printed by the -projecthelp
command-line
option.