I know it's mauvais ton to ask twice in a single day but here's another Maven puzzler:
I have a parent POM which defines 5 modules (5 subprojects). Since each module is executed in exactly the same way I pull <profile><build>
section into the parent POM to get rid of the duplicate code. Now - if I execute build individually from each module it works, however if I want to build all modules at once and move to the parent directory I got error since the very first thing Maven tries to execute is the parent project itself:
mvn package -P release
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO] DWD Parent project
[INFO] Projects
After that build fails because exec plugin tries to execute something that is not there. Looking at the output it is pretty obvious that reactor plugin is driving the build but how can I configure reactor to skip the parent?
P.S. To prevent confusion - I'm trying to suppress profile execution on parent and enable it on child during the same
build
You can't skip the parent build, but you can configure the profile to not be activated with a little hack. This answer shows how to control the activation of a profile by the presence or absence of a file-based <activation>
element. This way you can define the profile in the parent, but have it deactivated in that project because of the marker file being present in the parent. Child projects would not have the marker file in their source, so the profile would be activated for those projects.
Update to clarify: On my test project this configuration means the profile is deactivated in the parent project (which has the file in src/main/resources), but activated in all child projects which do not have the file in their resources directories.
<profile>
<id>test</id>
<activation>
<file>
<missing>src/main/resources/test.marker</missing>
</file>
</activation>
...
</profile>