ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: nested arguments
Date Wed, 05 Dec 2001 15:02:46 GMT
On Wed, 5 Dec 2001, Melroy Rodrigues <> wrote:

> can I use a variable 
> ${appserver.${}.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="${}.properties" />

and have property files for your different targets that define things
like appserver.home. So you'd have two property files containing


Another option involves a property setting target for each value can take:

<target name="check">
  <condition property="is.weblogic51">
    <equals arg1="${}" arg2="weblogic51" />
  <condition property="is.weblogic60">
    <equals arg1="${}" arg2="weblogic60" />

<target name="setup-properties-weblogic51" 
  <property name="appserver.home" value="foo" />

<target name="setup-properties-weblogic60" 
  <property name="appserver.home" value="bar" />

<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.${}" value="don't care" />

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.


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

View raw message