I would like to clarify the if
and unless
statements in ANT script
I have the following code:
<condition property="hasExtensions">
<contains string="${Product_version}" substring="Extensions">
</condition>
<exec executable="${TrueCM_App}\ssremove.exe" unless="hasExtensions">
...
</exec>
Does that mean the above <exec>
would execute ssremove.exe if Product_version
does not contain the string "Extensions"
?
Then how about the opposite case: if it contains the string "Extensions"
? Will my code look like this:
<condition property="hasExtensions">
<contains string="${Product_version}" substring="Extensions">
</condition>
<!-- here below it does not have the string "Extensions" -->
<exec executable="${TrueCM_App}\ssremove.exe" unless="hasExtensions">
...
</exec>
<!-- below is for if it has the string "Extensions" -->
<exec executable="${TrueCM_App}\ssremove.exe" if="hasExtensions">
...
</exec>
This is used to specify the treatment of text contents of the macro invocation. If this element is not present, then any nested text in the macro invocation will be an error. If the text element is present, then the name becomes an attribute that gets set to the nested text of the macro invocation. Since Ant 1.6.
A target is a container of tasks and datatypes that cooperate to reach a desired state during the build process. Targets can depend on other targets and Apache Ant ensures that these other targets have been executed before the current target.
Ant tasks are the units of your Ant build script that actually execute the build operations for your project. Ant tasks are usually embedded inside Ant targets. Thus, when you tell Ant to run a specific target it runs all Ant tasks nested inside that target.
You've got the logic right, but I'm not sure that the <exec>
task accepts the if
and unless
attributes. See the docs for more info.
You will probably need to wrap the <exec>
tasks in a target that checks the condition. For example:
<condition property="hasExtensions">
<contains string="${Product_version}" substring="Extensions">
</condition>
<target name="ssremove" unless="hasExtensions">
<exec executable="${TrueCM_App}\ssremove.exe">
...
</exec>
</target>
Then if you run ant ssremove
I think you will get what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With