ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mika Moilanen <>
Subject Dispatching based on property values
Date Thu, 18 Sep 2003 09:35:33 GMT

One day I was struggling with the problem of executing ANT targets
depending on the value of some property. I found one solution but I'd
like to know whether there are any alternatives being more
compact/elegant than the one I'm presenting here:

<project name="stuff" default="all" basedir=".">
<description>Dispatching based on the value of the property.</description>

<property name="important.criteria" value="Foo"/>

<target name="all" depends="eval_criteria">
  <antcall target="foo_rule"/>
  <antcall target="bar_rule"/>

<target name="foo_rule" if="foo">
  <echo message="running foo rule..."/>

<target name="bar_rule" if="bar">
  <echo message="running bar rule..."/>

<target name="eval_criteria">

  <condition property="foo">
    <equals arg1="${important.criteria}" arg2="Foo"/>

  <condition property="bar">
    <equals arg1="${important.criteria}" arg2="Bar"/>



Short, we examine the value of "important.criteria" and run either
"foo_rule" or "bar_rule" according to that.

Best Regards, 
----------------------------------------------------------  phone: +358-0-511-23587
Nokia Networks, PO box 320, FIN-00045 NOKIA GROUP, Finland

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message