This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Best Practices - Properties files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Best Practices - Properties files" Watch "Best Practices - Properties files" New topic
Author

Best Practices - Properties files

Ashish Gauswami
Greenhorn

Joined: Aug 20, 2008
Posts: 22
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.

Ashish
SCWCD - Preparing, SCJP - 86%
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

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 .


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
Don't get me started about those stupid light bulbs.
 
subject: Best Practices - Properties files
 
Similar Threads
Location of Property files
Property Files For Different Servers in WebSphere
Not the same Ant GUI app question
log4j...
Deployment practices for properties