ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: dynamically reading a property file
Date Fri, 13 Apr 2007 06:02:18 GMT

What exactly are you trying to achieve here?  In your example, you 
reference the name of the property you set the environment to....

<echo>${myprop.${env}.abc}</echo>

Why do you have the ".abc" there?  I would think your goal would be 
to define each "env" value as a property,eg.. abc=123, def=456, then 
reference the property without naming it.  Is that what you are 
aiming for?  How about...

ant -Denv=abc

     <expand prop="myprop.${env}"/>

     <macrodef name="expand">
         <attribute name="prop"/>
         <sequential>
             <echo>${@{prop}}</echo>
         </sequential>
     </macrodef>

Output is:  "123"


Jake

At 03:53 PM 4/11/2007, you wrote:
 >Hi there,
 >
 >Using ant, how can I dynamically read a property file?
 >
 >e.g.
 >
 ><property prefix="myprop"
 >file="${base.dir}/config/properties/myprop.properties" />
 >
 >so now to reference a property in that file
 >
 >foo=bar
 >
 >All I have to do is
 >
 ><echo>${myprop.foo}</echo>   // prints bar
 >
 >however, I don't know how to do something like this
 >
 >envAll=abc,def
 >
 >abc=abhay
 >def=pradhan
 >
 >
 >now, say I pass in -Denv=abc, something like this, dosen't work..
 >
 ><echo>${myprop.${env}.abc}</echo>
 >
 >where ${env} can be either abc or def
 >
 >am I doing something stupid?
 >
 >cheers
 >Abhay
 >
 >---------------------------------------------------------------------
 >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