File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best Practices - Properties files

 
Ashish Gauswami
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the best practice for maintaining different versions of properties files like for prod, test and dev and generate war/ear out of it selecting correct version of property file using Ant?

What I have done is I have kept all three version of properties file together with .prod and .test suffix for Production and Test, and for Development just .properties. In my Ant I have written three different targets and I am coping and renaming appropriate property file.

I use RAD7 and Websphere.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many ways to solve this problem, your method is a reasonable one. Another approach is to pass in an environment variable via the command line e.g. ant -Denv=dev and then use that to pick out the correct properties file ${env}.properties .
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17621
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I prefer not to make different builds for test/dev/prod. The problem with doing so is that if the production app goes down, you may have trouble keeping track of the different versions, and in some cases, the program code itself may even be different.

I get around this by creating a universal deployable and injecting the configuration information in on a per-server basis - typically via JNDI.

A side benefit of this is that if I need to do before and after comparisons, I can usually run 2 copies of the app on a single test machine just by deploying them with different contexts and configurations.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:Actually, I prefer not to make different builds for test/dev/prod.

Me too. I use different sets of property files so I just have to change the classpath of the app for the environment. (And of course other settings are in JNDI.)

I generate my property files since we have many environments. So I really only maintain one set of property files and another file with the differences.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic