We have a parent POM for our project which provides lot of configuration. In our project, we need to provide some more configuration if a certain profile is activated. We currently do it this way
<profiles>
<profile>
<id>prof1</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.somegroupId</groupId>
<artifactId>some-artifact</artifactId>
<configuration>
<someConfig combine.children="append">
<param>paramCommon</param>
<param>paramProf1</param>
</someConfig>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>prof2</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.somegroupId</groupId>
<artifactId>some-artifact</artifactId>
<configuration>
<someConfig combine.children="append">
<param>paramCommon</param>
<param>paramProf2</param>
</someConfig>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>prof3</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.somegroupId</groupId>
<artifactId>some-artifact</artifactId>
<configuration>
<someConfig combine.children="append">
<param>paramCommon</param>
<param>paramProf3</param>
</someConfig>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>prof4</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.somegroupId</groupId>
<artifactId>some-artifact</artifactId>
<configuration>
<someConfig combine.children="append">
<param>paramCommon</param>
<param>paramProf4</param>
</someConfig>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
The problem here is we repeat the whole build
everywhere. I would want to avoid that. I want to pass paramProfX
through a property. The plugin configuration here cannot be moved out of profiles as it must be included if and only if one of the four profiles is activated otherwise not.
Here, I can move paramCommon
and the rest of the build
tag in another profile with paramProfX
to be a property and pass paramProfX
through some other profile as a property. But, in that case I may need to activate both profiles simultaneously which I don't want to do as activating only one of the four profiles will do nothing and hence would be misleading.
What is the best way to achieve this if I would like to activate only one profile at a time?