I have 2 common plugin-driven tasks that I want to execute in my projects. Because they're common, I want to move their configuration to the pluginMangement
section of a shared parent POM. However, both of the 2 tasks, whilst otherwise completely distinct, use the same plugin. In some of my projects I only want to do 1 of the 2 tasks (I don't always want to run all executions of the plugin).
Is there a way to specify multiple different executions of a plugin, within the pluginManagement
section of a parent pom, and choose in my child pom one (and only one) of those executions to actually run? If I configure 2 executions in pluginManagement
, it seems that both executions will run.
Note: I think this may, or may not, be a duplicate of question Maven2 - problem with pluginManagement and parent-child relationship, but as the question is nearly 4 screenfuls long (TL;DR), a succinct duplicate might be worthwhile.
You're correct, by default Maven will include all of the executions you have configured. Here's how I've dealt with that situation before.
Note, the executions are bound to phase
none
. In the child, you enable the parts that should execute like this:If the child doesn't explicitly bind the execution to a phase, it won't run. This allows you to pick and choose the executions desired.