I have an ant
task like so:
<target name="mathWala" description="Some sample math operations.">
<if>
<islessthan arg1="${op1}" arg2="${limit}"/>
<then>
<echo>${op1} is less than ${limit}</echo>
<antcall target="adder"></antcall>
</then>
</if>
</target>
<target name="adder">
<math result="result" operand1="${op1}" operation="+" operand2="1" datatype="int"/>
<echo>result = ${result}</echo>
</target>
When I run the above task, the error I get is:
if does'nt support the nested "islessthan" element.
Can I use the <if>
and <islessthan>
statements together? I have gone through the documentation and did not find anything to suggest otherwise.
This is one of several bugs (for other oddities see here) in the latest version 1.0b3 of antcontrib,
but
<if><islessthen ...>
will work with version antcontrib 1.0b2 .Alternatively you may use a macrodef with builtin javascript engine (contained in jdk => 1.6.0_06) instead of using target + antcall which is considered bad practice.
Here's some snippet with adapted version of an answer to another question:
Intentionally used different math operations like -,+,*,/ instead of using
eval(...)
to restrict the operation types provided by macrodef.