2011-09-19 150 views
1

我在Ant中有兩個包含整數的屬性。我想檢查一個是否比另一個大。我怎麼能做到這一點?有沒有辦法在螞蟻中使用減法?然後,我可以只減去兩者並檢查結果是否大於0.螞蟻減法

謝謝!

回答

2

您可以嘗試使用此示例:

<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> 
1

使用常規任務

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

<groovy> 
properties["greater"] = properties["x"] > properties["y"] 
</groovy>