You examples below are a little confusing, so forgive me if I am completely missing the mark with this advice.
My suggestion is to not try to fit all the properties into a single file. Try creating a properties file for each environment. dev.properties =============== webpath=http://localhost:7001/cis-7.6.0 qa.properties ============= webpath=http://some-server.com:8185/cis-7.6.0 staging.properties ============== webpath=http://some-server2.com:8185/cis-7.6.0 Then in your build.xml you can load the appropriate properties file based on the value of another property, like ${env} for example. build.xml =========== ... <property file="${env}.properties"/> ... <!-- make sure the user set the env property when running ant --> <fail unless="env">You must specify the env property on the command line. For example: ant -Denv=dev </fail> So based in the value of ${env} you will have a different value for ${webpath}. You can do the same for other environment specific properties as well. I hope this helps. -Rob Anderson > -----Original Message----- > From: Sunil Goklani [mailto:[EMAIL PROTECTED] > Sent: Friday, May 19, 2006 6:06 PM > To: [email protected] > Subject: Dynamic references to properties files > > Hi All, > > I had a question on how I could use two variables to access > information from > my properties files. I am trying to build an ant script to generate > configuration files for all of my development, qa, and > staging environments. > > For example I have the following in a properties file: > > #Configuration for adapterconfig.xml > adapterconfig.webpath=<property > name="webPath">http://localhost:7001/cis-7.6.0</property> > assem1-adapterconfig.webpath=<property > name="webPath">http://some-server.com:8185/cis-7.6.0</property> > assem2-adapterconfig.webpath=<property > name="webPath">http://some-server2.com:8185/cis-7.6.0</property> > > The first property is what developers use and check/label > into the cvs. The > other values are what I am supposed to have for my respective > environments. > > Suppose I input "-Dset.environment=assem1" as a command line > argument. Is > there a way possible for me to access the value of > ${assem1-adapterconfig.webpath} with a variable combination of > "${${set.environment}-${adapterconfig.webpath}}". > > I tried it like that and I got an error because it was > replacing the actual > value of "adapterconfig.webpath" before it even got to where > I wanted it to. > > Second approach: > > I created a temp property and built out the correct string > <property name="p-temp" > value="${set.open}${set.environment}-adapterconfig.webpath${se > t.close}"/> > the set.open and set.close are the ${ and } respectively. > However now in my > destination file, it actually replaces with: > "${assem1-adapterconfig.webpath}" and not the value itself. > Is there anyway > I can make ant recognize this string as a property? > > Thanks all in advance! > > _________________________________________________________________ > Express yourself instantly with MSN Messenger! Download today > - it's FREE! > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
