1

Ant には、両方とも整数を含む 2 つのプロパティがあります。一方が他方よりも大きいかどうかを確認したい。どうすればそれを達成できますか?アリで減算を使用する方法はありますか? 次に、2 つを減算して、結果が 0 より大きいかどうかを確認します。

ありがとう!

4

2 に答える 2

3

このサンプルを使用してみることができます:

<scriptdef name="intCompare" language="javascript">
    <attribute name="leftside"/>
    <attribute name="rightside"/>
    <attribute name="diff"/>
    <![CDATA[
   var leftSide = attributes.get("leftside");
   var rightSide = attributes.get("rightside");

   project.setProperty(attributes.get("diff"), leftSide-rightSide);
 ]]>

</scriptdef>

<target name="test">
    <intCompare leftside="555" rightside="9" diff="deviation"/>
    <echo message="The difference is: ${deviation}"/>
</target>
于 2011-09-19T11:17:49.480 に答える
1

Groovy タスクを使用する

<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>

<groovy>
properties["greater"] = properties["x"] > properties["y"]
</groovy>
于 2011-09-19T18:22:08.357 に答える