Reputation: 1675
I have a maven project, which has quite different settings in the properties files for production and development envs. Is it right, that the most common way is to have different maven profiles (dev by default) which will package different properties during the build process? Is there maybe another way?
Upvotes: 2
Views: 103
Reputation: 97437
The problem with profiles is that you need to run your build the number of times of your profiles. Which means if have five profiles (dev, pre-test, pre-live, qa, prod) you need to run your build five times. I would suggest to go a different way and produce as a result of a build direct those five artifacts (usually war's etc.) which have been configured appropriately. This can be achieved by using the example i have produced which makes life easiert. The example will produce
Upvotes: 1
Reputation: 28961
There is another approach to put environment dependencies in an environment to have single artifact built from maven project and then provide properties during deployment. In this case maven doesn't know anything about particular environment.
E.g. you could put something -Dmy.config.file=/path/to/env/my.properties
in java command line or by using JNDI, or reading properties from database, and so on.
This is more viable approach if you have a lot of different environments or you don't know anything about them (e.g. distributing a .war
application to end-users).
Upvotes: 0
Reputation:
Yes, this is exactly what profiles are designed for.
You don't even need different properties files, you can have one property file that gets filtered with different properties from each profile
.
Upvotes: 4