Im using ant-contrib to implement a greater-than (for ints only)
functionality.
Did I miss something in the documentation? Or is this the best approach (i
realize I could have written a custom ant task)

Did i reinvent some wheel in ant?

 <target name="t">
   <taskdef resource="net/sf/antcontrib/antlib.xml">
    <classpath>
      <pathelement location="ant-contrib-0.6.jar"/>
    </classpath>
  </taskdef>

   <macrodef name="greaterthan">
      <attribute name="resultprop" default="NOT SET"/>
      <attribute name="arg1" default="NOT SET"/>
      <attribute name="arg2" default="NOT SET"/>
      <sequential>
        <math result="gt_tmp" datatype="int">
          <op op="max" >
            <num value="@{arg1}"/>
            <num value="@{arg2}"/>
          </op>
        </math>
        <echo>${gt_tmp}</echo>
        <if>
          <equals arg1="@{arg1}" arg2="${gt_tmp}" />
          <then>
            <property name="@{resultprop}" value="1" />
          </then>
          <else>
            <property name="@{resultprop}" value="0" />
          </else>
        </if>
      </sequential>
   </macrodef>

   <greaterthan arg1="100" arg2="20" resultprop="well" />
   <echo>${well}</echo>
 </target>

Reply via email to