Reputation: 31
I use maven to build my java based program. It is work fine. But now I meet an issue which request me to build a revision for other users which is based on the same source code with a little different(e.g. different software name, and different resource file).
Does anyone have any idea about how to do it?
Upvotes: 0
Views: 869
Reputation: 29
You can create different profiles within your POM for the different builds you want to do.
Here are some of the example part of POM.xml
<!-- Define profiles here and make DEV as default profile -->
<profiles>
<!-- dev Profile -->
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- qa Profile -->
<profile>
<id>qa</id>
<properties>
<env>qa</env>
</properties>
</profile>
<!-- prod Profile -->
<profile>
<id>prod</id>
<properties>
<env>prod</env>
</properties>
</profile>
</profiles>
...
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
Upvotes: 0
Reputation: 4014
Depending on the type of project, the most "maven" way to do this would be to split up the project into a parent with multiple children. Your main project is put into one module and each of user specific configurations goes into a different module, which can then depend on the common code.
Each of the user specific modules can have their own resources and unique configuration, which would make producing different named configurations easier. It would also make any user specific coding tweaks easier.
Upvotes: 0
Reputation: 12258
You need to use profiles. It's a little complicated to explain in an answer like this, but essentially, you will create different profiles within your POM for the different builds you want to do. You will choose the profile at build time, using, e.g., a variable definition in the mvn command line, and within the profile, you change any of the variables or settings that you need to change. Lots more info is available here.
Upvotes: 6