I have a very complex multi-module Maven project with nested projects. basically, the problem can be simplified to this configuration :
Project A
| pom.xml
| pomBis.xml
|
|---- Project B
pom.xml
pomBis.xml
---- Project D
pom.xml
---- Project E
pom.xml
|---- Project C
pom.xml
The pom of the Project A has Project B and C as modules. And in the pom of Project B, I only have Project D. Because Project E is a very large project that we don't need to compile everyday, it is excluded of the daily build.
I now want to execute a Maven command, for example the versions:update-parent. I want ALL my projects and sub-project to be updated. If I use the pom.xml, the Project E will not be updated because it is not declared as a sub-module of Project B.
I thought of creating a custom pomBis.xml that would be used. But if I create a pomBis.xml on each sub-project, and run the command, only the pomBis.xml of Project A is used. When Maven is going deeper, it falls back to normal pom.xml.
The only solution I see is to create a pomBis.xml in Project A that will list all sub-modules and really list all leaf projects.
Am I getting something wrong?
Maven profile is the answer.
Project A POM:
<pom>
.
.
.
<modules>
<module>B</module>
<module>C</module>
<modules>
</pom>
Project B POM:
<pom>
.
.
.
<profiles>
<profile>
<id>includebeast</id>
<modules>
<module>E</module>
<modules>
</profile>
</profiles>
<modules>
<module>D</module>
<modules>
</pom>
Now, when you want your maven command affect all your projects, activate the profile "includebeast" as like below example:
Example to compile all : mvn clean compile -P includebeast