• 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

replace a content of a file based on build.properties

 
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on build.xml file. I have completed and I have got the output as well..

Now my concern is how do I replace a content in an application.property file based on a value from my build.properties.

In my build.xml file I have to replace the value of deploy.mode in a property file as dev, test or prod based on the build.property file..

Can anyone advise..
 
Saloon Keeper
Posts: 27853
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The rule for Ant is whoever defines a property first wins. That's the opposite of most environments, where the last definition is the one that's taken.

An easy way to do what you want is to take advantage of the fact that Ant is a Java app and Java apps can be passed properties via the command line:

ant -Ddeploy.mode=test target-name
 
rahulJ james
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand your point from the command line...Say If I wanted to replace few other values in my property file other than this deploy.mode.. How do i do the same?
 
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
One way is to add the extra property values to the command line.

Another way is to set up your build.xml to load another properties file before your build.properties file. The user could then override property values using that file, and thus save a lot of typing on the command line.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic