I am trying to avoid antcall in my program, so trying to move antcall targets to target dependencies. Now I have a situation:
<target name="test" depends="a,b,c" />
<target name="a" depends="a1,a2,a3" />
<target name="b" depends="b1,b2,b3" />
<target name="c" depends="c1,c2,c3" />
Till now every thing work fine. But if i just want to skip target 'c' and its dependencies from execution,
<target name="c" depends="c1,c2,c3" if="skip.c" /> (considering the property "skip.c" is already set)
Now the dependencies of target 'c' will be executed and then it checks for condition "skip.c".
Is there a better solution, where both target and its dependencies wont execute based on condition.
I can always go for antcall with if conditions. But looking for any another alternative.
I cant check for "skip.c" conditions in c1,c2,c3 targets as i have more conditions to check in those targets.
To avoid using the antcall, you would need to put the condition in each of the sub-tasks. Looking at the name "skip.c", it is probably an "unless" condition, like this:
If you need to do the processing of the conditions at the moment you run task "c", you could do it in a target "check_run_c" like this:
If there are also instructions in the task "c" that you only want to run conditionally:
All dependencies of a target are processed before the "if/unless" test is looked at. There is no built-in method in Ant to avoid this.
Instead, a good approach is to separate the dependencies from the actions. Try the following: