ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Ivanov <rambiusparkisan...@yahoo.com>
Subject Re: Nested Variables in ANT?
Date Wed, 09 Jun 2004 14:52:40 GMT
It can (almost):

<property name="qa" value="location-qa"
refid="qa.env"/>
<property name="dev" value="location-dev"
refid="dev.env"/>
<property name="envir" value="${dev}"/>
<property name="location" refid="${envir}.env">
<echo>${location}<echo>

If you invoke this it will echo
location-dev.
In you invoke this with ant -Denvir=qa, it will echo
location-qa.

This is a litle bit tricky. A better decision is to
encapsulate your environment specific properties in
properies files, say qa.properties and dev.properties.
In your build.xml file that you do this:
<property name="envir" value="dev"/>
<property file="${envir}.properties">

When you invoke this, it will pickup properties from
dev.properties file.
If you invoke it with ant -Denvir=qa, it will pickup
properties from
qa.properties.

I think that the second is better since, you may found
there there must be more than one property that will
be differen for dev "case" and qa "case". But if you
have only one property to be different (I've had it
once), you can go with first.

HTH Ivan

--- "Mattos, John" <jmattos@Indemand.com> wrote:
> Hi All
> 
>  
> 
> I'd like to use properties in a target that vary
> depending on a parameter
> sent in... for example instead of
> 
>  
> 
> <target name="dev-target">
> 
>       <echo massage = "${location.dev}>
> 
> </target>
> 
> <target name="qa-target">
> 
>       <echo massage = "${location.qa}>
> 
> </target>
> 
>  
> 
> I have a variable called ${envir} and I'd like to do
> something like
> 
> <target name="general-target">
> 
>       <echo massage = "${location.${envir}}>
> 
> </target>
> 
>  
> 
> Can I do anything like this? It doesn't seem to like
> the nested ${} 's
> 
>  
> 
> John 
> 
>  
> 
> 



	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

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


Mime
View raw message