2012-04-18 18 views
4

2つの値を比較する必要があるantタスクがあります。 2つの値が等しくない場合、私は失敗したいと思います:Ant: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."/> 

アリ出力によると、両方の値は、releaseNotesVersionおよびアプリケーションバージョンが同じ値1.7を持っていますが、条件が常にtrueと評価 - どのではないため、は数字が等しくないことを意味します。それで、蟻がそのような価値観を比較するのに苦労するのではないかと思います。

答えて

13

例では、2つのリテラル文字列が一致しています。これらは決して等しくないので、あなたの状態は常に真と評価されます。 argが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."/> 
+0

+1ありがとうございます!私は私のベッドの時間xDを過ぎてwaaayされている必要があります... – AgentKnopf

関連する問題