if-then-else Task

ModelAnt’s util package provides if-then-else task to evaluate dynamically any ANT condition and do conditional processing. The unusual of this task is that ANT actually does not allow such dynamic evaluation – it is just one time set up and evaluated. The ModelAnt’s if task is specifically designed for repeating tasks execution with different parameters, within iterative tasks for example within ModelAnt for task.

The if task dynamically evaluates the nested condition and executes the tasks provided in the nested <then> or <else> section:

  • the condition is a single one and mandatory
  • the conditions to use are standard ANT conditions
  • of course complex condition can be formulated using the standard ANT and, or and not conditions
  • the <then> and <else> tasks lists are optional

See the documentation of if-then-else task.

For example, when run in  modelant/util/test/xml directory, this fragment:

  <fileset dir=".">
    <include name="*.xml"/>
      <matches string="${this}" pattern="test-l.*$"/>

produces the output:

[echo] test-list.xml 
[echo] test-local.xml

Note that this fragment is also an example of use of ModelAnt for task together with an ANT standard file set.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.