This post originated from an RSS feed registered with Java Buzz
by dion.
Original Post: Starting a new project: Where to put config files?
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Whenever I am with a new project team, one of the early questions arise around the issue of "where to put stuff".
With typical J2EE projects you end up with various config files that AT DEPLOMENT want to be in different places.
For example:
WEB-INF: At the root you will have a web.xml, and other beasts such as sitemesh.xml
WEB-INF/classes: This covers the "has to be in the classpath" issue. Here you will often find an applicationContext.xml, log4j.xml, message bundles, and more.
META-INF: Here you will have some EJB-ish stuff (if you are using EJB ;)
Spread out: Your Hibernate .xml files may be in various locations, etc
I normally run across two styles on how to handle this:
One Place For Dev. Then Build To The Right Place
In this mode, there is a /src/config, or something like it, which has ALL of the XML, and properties files. This makes things very simple to find when you need to get to a config file, as you don't find yourself hunting around in all of the various places that it could be.
The responsibility of putting these files in the correct places falls on the build master. In your source control you don't even HAVE a WEB-INF directory. The build creates this and sets it all up for you on the fly.
The problem is that if you are debugging, you often find yourself "checking out what is on the deployed server". Here there is no longer a nice config directory, and you are slower at finding the files as you don't really know where they are meant to go.
Mimic The Deployment Structure
In this scenario you simply mimic the end structure. You cringe when you check-in a directory called WEB-INF/classes to source control, which has config files that need to be in the classpath.
Although the files are spread out all over the shop, they do mimic the Real World, and hence you can find things quickly in that world.
A Bit Of Both
The scary scenario is when you see projects that do a bit of both. At this point you don't have a clue where anything is :)
Smart Folder
Maybe you can get a bit of the best of both worlds if you had a Smart Folder. Then, the config directory could aggregate the config files from everywhere else, but they would just be symlinks. WinFS can make this easy. On *NIX you can just have a script which generates the symlinks for you!