Ticket #186 (closed defect: fixed)
targets are executed even if the target that depend on them is skipped using if/unless
| Reported by: | Bruce Weirdan | Owned by: | hans |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | documentation | Version: | devel |
| Keywords: | Cc: |
Description
Either it's not clear from the documentation or is a bug: when I have conditional target (using "if"/"unless" attribute) and target is not to be executed due to the failed condition, the targets listed in its "depends" are still executed.
Test case: see attached file. What I expect is that path2-prereq target should be skipped, but it's still executed, even though the target that triggered it execution is not.
Attachments
Change History
comment:1 Changed 4 years ago by bender
My vote is that the documentation needs to be updated. Phing is basically a port/clone of Apache Ant and the Ant user manual is clear on the subject:
Important: the if and unless attributes only enable or disable the target to which they are attached. They do not control whether or not targets that a conditional target depends upon get executed. In fact, they do not even get evaluated until the target is about to be executed, and all its predecessors have already run.
http://ant.apache.org/manual/using.html#targets
This behavior is fairly fundamental to the circular reference and dependency resolution. As pointed out in the same Ant manual page, using a dependent task to set a property is also the only way to accomplish a compound if or unless conditional check.

