ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "McHenry, Matt" <mmche...@carnegielearning.com>
Subject RE: nested arguments
Date Fri, 07 Dec 2001 00:00:31 GMT
If you check the archives, you'll find a pair of tasks called ForEach and
PropertyCopy, posted by Matthew Inger 09/21/01.  The latter task will do
exactly what you're looking for, e.g.:

<propertycopy name="NewVar" from="a.${b}.c" />

Matt McHenry
Software Developer
Carnegie Learning
www.carnegielearning.com

> -----Original Message-----
> From: Stefan Bodewig [mailto:bodewig@apache.org]
> Sent: Wednesday, December 05, 2001 10:03
> To: ant-user@jakarta.apache.org
> Subject: Re: nested arguments
> 
> 
> On Wed, 5 Dec 2001, Melroy Rodrigues <meldiscuss@yahoo.com> wrote:
> 
> > can I use a variable 
> > ${appserver.${appserver.target}.home} in the build.xml
> > file
> 
> No - no recursive property expansion in Ant.
> 
> > and if not what is the equivalent.
> 
> I'm not sure what you are trying to do here, I assume you want to
> define things like
> 
> <property name="appserver.weblogic51.home" value="foo" />
> <property name="appserver.weblogic60.home" value="bar" />
> 
> and use the above construct.  I also assume that you want to use more
> than one property, otherwise <condition> and its nested <equals>
> element are your friend.
> 
> The cleanest solution probably is something like
> 
> <property file="${appserver.target}.properties" />
> 
> and have property files for your different targets that define things
> like appserver.home. So you'd have two property files containing
> 
> weblogic51.properties:
> ======================
> appserver.home=foo
> 
> and 
> 
> weblogic60.properties:
> ======================
> appserver.home=bar
> 
> 
> Another option involves a property setting target for each value
> appserver.target can take:
> 
> <target name="check">
>   <condition property="is.weblogic51">
>     <equals arg1="${appserver.target}" arg2="weblogic51" />
>   </condition>
>   <condition property="is.weblogic60">
>     <equals arg1="${appserver.target}" arg2="weblogic60" />
>   </condition>
>   ...
> </target>
> 
> <target name="setup-properties-weblogic51" 
>         depends="check"
>         if="is.weblogic51">
>   <property name="appserver.home" value="foo" />
> </target>
> 
> <target name="setup-properties-weblogic60" 
>         depends="check"
>         if="is.weblogic60">
>   <property name="appserver.home" value="bar" />
> </target>
> 
> <target name="setup" 
>         
> depends="setup-properties-weblogic51,setup-properties-weblogic60" />
> 
> A pre-Ant 1.4 solution that works along the same line but doesn't need
> a condition task (but is a lot more hacky IMHO) would replace 
> the check
> target with
> 
> <target name="check">
>   <property name="is.${appserver.target}" value="don't care" />
> </target>
> 
> I prefer the property file version, it may scatter your properties
> into several files and it may be more difficult to keep them in sync
> when you add new properties (as you have to remember to change all
> files), but it makes the build file a lot easier to read.  All IMHO,
> of course.
> 
> Stefan
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message