Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant: Check if two numbers are equal

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 ?

like image 881
AgentKnopf Avatar asked Apr 18 '12 20:04

AgentKnopf


1 Answers

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."/>
like image 195
gareth_bowles Avatar answered Sep 23 '22 23:09

gareth_bowles