Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Ant Less Than

Tags:

ant

How on earth do you check a number property is less than in Apache Ant?

<property name="small" value="15"/>
<property name="big" value="156"/>
<fail message="small is less than big!">
  <condition>
    <lessthan val1="${small}" val2="${big}"/>
  </condition>
</fail>

From what I've seen (I'm new to Ant) you can only do <equal/>?

like image 313
Matt Clarkson Avatar asked Sep 30 '11 21:09

Matt Clarkson


1 Answers

You could use a <scriptcondition> (see http://ant.apache.org/manual/Tasks/conditions.html).

Read the documentation carefully because it would need installing additional jar dependencies in ant.

The condition could look like that (not tested):

<scriptcondition language="javascript">
    var small = parseInt(project.getProperty("small"));
    var big = parseInt(project.getProperty("big"));

    self.setValue(small < big);
</scriptcondition>
like image 50
JB Nizet Avatar answered Sep 28 '22 08:09

JB Nizet