ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <>
Subject Re: Setting the value of a property conditonally
Date Fri, 04 Aug 2006 14:43:35 GMT
--- wrote:

> I've been testing the <condition> task and either it
> is very limited in its functioning or I am carrying
> the wrong mental model into the exercise.

Charles, I am going back to your initial mail to
address your statement of having the wrong mental
model.  Here is where you originally hit the
proverbial nail on the head.  Ant's condition task was
designed with the simplest paradigm in mind:  if, if,
if.  <condition>'s 'else' attribute is a recent
addition as the manual attests (since 1.6.3, which for
all practical purposes, means since 1.6.5, i.e. the
current version).  'else' can be used for convenience
when you don't want to say:

<condition name="foo" value="foo">
  <equals arg1="${arg}" arg2="FOO" />

<condition name="foo" value="bar">
  <not><equals arg1="${arg}" arg2="FOO" /></not>

Obviously here it is easy to use:

<condition name="foo" value="foo" else="bar">
  <equals arg1="${arg}" arg2="FOO" />

So for more complex situations you could simply use
multiple conditions as you would e.g. multiple ifs in
code, arranged from highest to lowest priority.  But
for the particular task you are describing here, I
might well take Antoine LL's advice and write a custom

> I work mostly in XSLT these days. There I can set
> the value of a variable by testing any number of
> conditions and nested conditions using the
> <xsl:choose> element.
> <condition> appears to be based on the
> "if-then-else" model. What I'm looking for is a
> means of setting a property on the
> "if-then-else-elsif" model.
> Is there some way of doing this with ant 1.65 as it
> stands or do I have to write an extension to
> accomplish this?
> Thanks.
> -- 
> Charles Knell
> - email
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

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

View raw message