wajid mehraj
wajid mehraj

Reputation: 263

Restrict values to ant Property task

What is the simplest implementation to restrict values to a property?

property name="prop_name"  value="${dynamic_value}

I want to have the values to ${dynamic_value} from a restricted set.

Thanks, Wajid

Upvotes: 0

Views: 268

Answers (1)

Rebse
Rebse

Reputation: 10377

You may use a scriptcondition (see ant manual conditions) with builtin javascript engine
(included in Java >= 1.6.x), f.e. :

<project>
 <property name="foo" value="26"/>
 <fail message="Value of $${foo} not in range => [${foo}] !">
  <condition>
   <scriptcondition language="javascript">
    var foo = parseInt(project.getProperty("foo"));
    self.setValue(foo &lt;= 20 || foo &gt;= 25);
   </scriptcondition>
 </fail>
</project>

Upvotes: 1

Related Questions