maven - Can I configure multiple plugin executions in pluginManagement, and choose from them in my child POM? -
i have 2 common plugin-driven tasks want execute in projects. because they're common, want move configuration pluginmangement section of shared parent pom. however, both of 2 tasks, whilst otherwise distinct, use same plugin. in of projects want 1 of 2 tasks (i don't want run executions of plugin).
is there way specify multiple different executions of plugin, within pluginmanagement section of parent pom, , choose in child pom 1 (and one) of executions run? if configure 2 executions in pluginmanagement, seems both executions run.
note: think may, or may not, duplicate of question maven2 - problem pluginmanagement , parent-child relationship, question 4 screenfuls long (tl;dr), succinct duplicate might worthwhile.
you're correct, default maven include of executions have configured. here's how i've dealt situation before.
<pluginmanagement> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>some-maven-plugin</artifactid> <version>1.0</version> <executions> <execution> <id>first-execution</id> <phase>none</phase> <goals> <goal>some-goal</goal> </goals> <configuration> <!-- plugin config share --> </configuration> </execution> <execution> <id>second-execution</id> <phase>none</phase> <goals> <goal>other-goal</goal> </goals> <configuration> <!-- plugin config share --> </configuration> </execution> </executions> </plugin> </pluginmanagement> note, executions bound phase none. in child, enable parts should execute this:
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>some-maven-plugin</artifactid> <executions> <execution> <id>first-execution</id> <!-- sure use id parent --> <phase>prepare-package</phase> <!-- whatever phase desired --> </execution> <!-- enable other executions here - or don't --> </executions> </plugin> if child doesn't explicitly bind execution phase, won't run. allows pick , choose executions desired.
Comments
Post a Comment