• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get property based on runtime value

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi- I want to set a property value based on run time value

I tried below and it doesn't work

Sample Build File
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxx
<project name="app">
<property file="build.properties"/>
<target name="test123">

<echo> Start</echo>
<echo>${env}</echo>
<echo> the value ${${env}_hostname}</echo>
<echo>end</echo>

</target>
</project>


build.properties file
dev_hostname=d001
sit_hostname=t005
qa_hostname=t001
ps_hostname=u001
prod_hostname=p001


XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx

C:\test>ant -f build_app.xml test123 -Denv=qa
Buildfile: C:\test\build_app.xml

test123:
[echo] Start
[echo] qa
[echo] the value ${${env}_hostname}
[echo] end

BUILD SUCCESSFUL
Total time: 0 seconds

I want to echo value for qa_hostname t001. I have multiple property values based for env variable ( ie dev_username,dev_password,dev-port).
I also have many build files which uses this property file. I don't want to set the property values inside build.xml

Any input will be appreciated.

Thanks,




 
Anil Patel Iii
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it resolved my self.

To achieve this we have to use propertycopy task in ant-contrib-0.6.jar


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic