I have an ant task which should compare two values for equality. If the two values are not equal, I'd like to fail:
<condition property="versionDoesNotMatch">
<not>
<equals arg1="applicationVersion" arg2="releaseNotesVersion"/>
</not>
</condition>
<fail if="versionDoesNotMatch" message="Version of Application and Release notes does not match."/>
According to the ant output, both values, releaseNotesVersion and applicationVersion have the same value 1.7 but the condition always evaluates to true - which because of the not would mean, that the numbers are not equal. Which makes me wonder, if ant would have troubles comparing those kind of values ?
You're matching two literal strings in your example; these will never be equal and so your condition always evaluates to true. Assuming that your args are Ant properties, you need to evaluate the property values like this:
<condition property="versionDoesNotMatch">
<not>
<equals arg1="${applicationVersion}" arg2="${releaseNotesVersion}"/>
</not>
</condition>
<fail if="versionDoesNotMatch" message="Version of Application and Release notes does not match."/>
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