Skipped targets are still executed
March 20th, 2009
Applies to:
Ant
Description:
Occurs while using Apache Ant.
Cause:
You have a target You want to skip if a property is set, so You have unless=”property” as an attribute of the target, but all the targets this target depends on are still executed.
The list of dependencies is generated by Ant before any of the targets are run. This allows dependent targets, such as an init target, to set properties that can control the execution of the targets higher in the dependency graph. This is a good thing., instead of specifying them inside the depends attribute.
However, when your dependencies break down the higher-level task into several smaller steps, this behaviour becomes counter-intuitive. There are a couple of solutions available:
1. Put the same condition on each of the dependent targets.
2. Execute the steps using