Subtraction in ant
I have two properties in Ant that both contain integers. I want to check if one is greater t开发者_StackOverflow社区han the other. How can I accomplish that? Is there a way to use subtraction in ant? Then I could just subtract the two and check if the result is greater than 0.
Thanks!
You can try to use this sample:
<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>
Use a groovy task
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>
<groovy>
properties["greater"] = properties["x"] > properties["y"]
</groovy>
精彩评论