tags:

views:

83

answers:

1

First some background information:

We have three environments for our EJB3 application: test, development and production. All require database settings of their own. We use maven2.

Data source settings are placed in ear project, directory /src/main/application/META-INF/data-sources.xml. File contains attributes for three different connection factories (one for each environment). However, only one of those can be active when the application is compiled, and the other two must be commented out.

It's a very common mistake to forget to modify the data-sources.xml before compiling the application to another environment, and this naturally causes interesting issues - and the burden of recompiling and -deploying.

It would be great if we could have three different data-sources.xml files (one for each environment), and depending on the command line switches one could specify which file was included in the ear. Something like this:

mvn install dev
mvn install prod
mvn install test

Is there a way to accomplish this?

+2  A: 

Maven has the concept of profiles for this kind of things: Building For Different Environments with Maven 2

rodrigoap