ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ckn...@onebox.com
Subject RE: RE: Re: Setting the value of a property conditonally
Date Fri, 04 Aug 2006 20:01:39 GMT
If anyone was still scratching his or her head over my inability to see what's in front of
me, please stop before you bleed. I've got it worked out.
-- 
Charles Knell
cknell@onebox.com - email



-----Original Message-----
From:     cknell@onebox.com
Sent:     Fri, 04 Aug 2006 13:18:32 -0400
To:       user@ant.apache.org
Subject:  RE: Re: Setting the value of a property conditonally

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?

Thanks.
-- 
Charles Knell
cknell@onebox.com - email



-----Original Message-----
From:     Matt Benson <gudnabrsam@yahoo.com>
Sent:     Fri, 4 Aug 2006 07:43:35 -0700 (PDT)
To:       Ant Users List <user@ant.apache.org>
Subject:  Re: Setting the value of a property conditonally

--- cknell@onebox.com 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>

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

Obviously here it is easy to use:

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

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
task.

HTH,
Matt
> 
> 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
> cknell@onebox.com - email
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message