"exec" does not support either if or if, so ChrisH's answer is correct. Usually, you also transfer the condition to the target and make it dependent on another target:
<target name="-should-ssremove"> <condition ... </target> <target name="ssremove" depends="-should-ssremove" unless="hasExtensions"> ...
Pay attention to the idiom of launching a target with a hyphen (-should-ssremove) to prevent its use from the command line. (You cannot make "ant -should-ssremove" because ant will consider it as an argument instead of a target - this is described in the ant manual)
Another smart idiom to use in this case, also from the manual, is to use the old "defined" if / except value and the new (starting with ant 1.8) extension and comparison with true / false.
This will give you:
<target name="-should-ssremove" unless="hasExtensions"> <condition ... </target> <target name="ssremove" depends="-should-ssremove" unless="${hasExtensions}"> ...
Note the difference: the first target uses the plain old, unless the second target extends the hasExtensions variable (using $ {}, which are not used in the first goal) and only works if it expands to true (which is the default value which is "available" will be installed on it, but you can set by adding the attribute "value" to "available")
The advantage of this idiom is that you can set the hasExtensions property from the outside, to a file that imports this (e.g. build.xml) or on the command line:
ant -DhasExtensions=true ssremove
This works because the -should-ssremove target will not be executed if hasExtensions is already defined (which up to 1.8 is the only logic supported by if / except). Therefore, your external definitions of trump cards - after all. On the other hand, the ssremove target will only work if the hasExtensions property is false. And this will always be determined by the validation time - thanks to the dependency on -should-ssremove.
Rhubarb
source share