• 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 can I de-hard code these values in my build.xml script?

 
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm using Ant 1.7. I'm trying to de-hardcode a few things from my script, and would prefer to have them properties-file driven. However, I'm not sure how to go about it. I have



I would like to move the hosts and ports into a properties file and then load them into this task dynamically. Any ideas how to do this?

Thanks, - Dave
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something like

<property file="${user.home}/build.properties" />

would do the trick for settings that apply to all your projects. If it's just for one project you can keep the properties in the project folder:

<property file="build.properties" />
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks ... I actually know how to include a properties file, but what I'm asking is how would I take a property like this ...



and turn it into part of my target ...



? The tricky part is the fact that there could be an arbitrary number of comma separated hosts in the properties file.

- Dave
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only way I know isn't quite as simple as a properties file.

I manually wrote a .json file, then created a class that reads in the JSON using a BufferedReader. A stringBuilder takes the input from the file, then I make a JSONObejct out of it (using the net.sf.json.JSONObject package). Then, store these values into a map that contains another class that I wrote that actually hold the values. It takes a little bit of effort but ends up working quite well.
 
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm just curious on the next step. Once the required object is available, how do we access that object in ant file. Is there any library that can be used here?
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try using the antcontrib (http://ant-contrib.sourceforge.net/). It has a <for> and a <foreach> task.
 
reply
    Bookmark Topic Watch Topic
  • New Topic