This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get property based on runtime value

 
Anil Patel Iii
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
  • 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


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic