You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Melroy Rodrigues <me...@yahoo.com> on 2001/12/05 15:51:00 UTC
nested arguments
I was wondering if I could use something like
I have defined appserver.target=weblogic51 in the
buil.properties
can I use a variable
${appserver.${appserver.target}.home} in the build.xml
file and if not what is the equivalent.
Thanks
Melroy
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: nested arguments
Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 5 Dec 2001, Melroy Rodrigues <me...@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
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>