Ant: Check if two numbers are equal
23,825
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."/>
Author by
AgentKnopf
Updated on July 09, 2022Comments
-
AgentKnopf almost 2 years
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 ?