my multi module project has the following structure:
parent
module 1 <-- inherits from parent via <relativePath>../parent/pom.xml</relativePath>
module 2 <-- inherits from parent via <relativePath>../parent/pom.xml</relativePath>
aggregator <-- aggregates modules with <modules><module>
The aggregator calls the following plugin:
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>some path</destFile>
</configuration>
</execution>
</executions>
<configuration>
<append>true</append>
</configuration>
</plugin>
</plugins>
</build>
The plugin is called for the aggregator, but i want to call it for all modules (1 and 2).
I know that i can change the parent pom, but i want to keep it clean (that change is part of a bigger implementation).
Is it possible to configure the plugin in such a way, that its called for all modules (just like being placed in parent pom)?
In short: No.
The only way for a module to get a plugin in a lifecycle not defined in its own POM is by inheriting the configuration from its parent.
You should really consider merging parent and aggregator into a single project, i.e. making the aggegrator also the parent. It is much cleaner that way.