I'm trying to write a parent pom, and I have a plugin defined, but I need to change the config for all inherited instances. So, I can put some configuration in the <pluginManagement>
definition, and I can override it in the <plugin>
, but how do I get the children to default back to the <pluginManagement>
version?
<build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> <executions...> <configuration> <configLocation> (used by all children) </configLocation> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <configLocation> (unique to the parent) </configLocation> </configuration> </plugin> </plugins> <build>
So, what happens is the children continue to show the parent's config.
Plugins declared outside of <pluginManagement> are inherited by child POMs, by default. Their settings can be overridden by each child if desired.
Overriding configurations from a parent pom can be done by adding the combine. self="override" attribute to the element in your pom. It appears that for Maven2. 2.1 if you do this in a profile it doesn't merge with plugins defined in parent profiles but overrides them.
pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one.
Ok, I think I have it. The answer, in my case, relates to what you specified - I did need the tag. However the solution was in the tag; by binding it to a non-phase, it does execute. This I knew. What I discovered is that the had to match in order for it to override. Thus, the config never gets parsed and doesn't matter.
<build> <pluginManagement> <plugins> <plugin> <!-- Main declaration of the plugin --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> <executions> <execution> <!--This must be named--> <id>checkstyle</id> <phase>compile</phase> <goals> <goal>check</goal> </goals> </execution> </executions> <configuration...> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <!-- Uses the default config --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <inherited>false</inherited> <executions> <execution> <!--This matches and thus overrides--> <id>checkstyle</id> <phase>none</phase> </execution> </executions> </plugin> </plugins> </build>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With