ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: Re: Setting the value of a property conditonally
Date Fri, 04 Aug 2006 17:18:32 GMT
Thanks to everyone who contributed. I now know the design decision that lays behind the functioning
of <condition>.

My Java is only now having the rust knocked off it, so I'm chary of trying to write a custom
task for this purpose. I have been working on Plan B, creating the intermediate XML file from
which I hope to load the properties.

I have set up a test harness build.xml file and sucessfully generated the properties XML file
and loaded the values from it to the build environment. The issue I'm now struggling with
is the timing of the loading of the property values.

If I put the <xmlproperty> element as a child of <project> and set the <xslt>
task as the default, the properties are loaded from the file as soon as ant starts to run.
While this is not surprising, it doesn't get me what I want.

What I'm looking to do is generate the XML properties file first and then read the values
from it.

Is there some way to do this?

Charles Knell - email

-----Original Message-----
From:     Matt Benson <>
Sent:     Fri, 4 Aug 2006 07:43:35 -0700 (PDT)
To:       Ant Users List <>
Subject:  Re: Setting the value of a property conditonally

--- 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:

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

View raw message