7

2 つの値が等しいかどうかを比較するアリのタスクがあります。2 つの値が等しくない場合は、失敗したいと思います。

<condition property="versionDoesNotMatch">
  <not>
    <equals arg1="applicationVersion" arg2="releaseNotesVersion"/>
  </not>
</condition>
<fail if="versionDoesNotMatch" message="Version of Application and Release notes does not match."/>

Ant の出力によると、値 releaseNotesVersion と applicationVersion の両方の値は同じ1.7 ですが、条件は常に true と評価されます。これは、notが意味するため、数値が等しくないことを意味します。ant がこれらの種類の値を比較するのに問題があるのだろうか?

4

1 に答える 1

18

この例では、2 つのリテラル文字列を一致させています。これらが等しくなることはないため、条件は常に true と評価されます。引数が Ant プロパティであると仮定すると、次のようにプロパティ値を評価する必要があります。

<condition property="versionDoesNotMatch">
  <not>
    <equals arg1="${applicationVersion}" arg2="${releaseNotesVersion}"/>
  </not>
</condition>
<fail if="versionDoesNotMatch" message="Version of Application and Release notes does not match."/>
于 2012-04-18T20:27:27.587 に答える