title: Controlling Maven plugin inheriting per execution
body: <p>I have a project which is comprised of a parent POM and a module (let’s call it “lib”). In the parent POM, I define a plugin with two executions (used to be only one). One of the executions (the new one) must be inherited by the module, the other mustn’t.</p>
  <p>So the structure is currently this:</p>
  <ul>
  <li>toplevel/pom.xml (no parent; parent POM plus <code>&lt;module&gt;lib&lt;/module&gt;</code>)</li>
  <li>toplevel/lib/pom.xml (parent: <code>../pom.xml</code>)</li>
  </ul>
  <p>I used to have <code>&lt;inherited&gt;false&lt;/inherited&gt;</code> in the plugin configuration; this obviously won’t work any more now.</p>
  <p>I defined a profile <code>build-this</code> with which the build is invoked, and I thought to maybe just split the plugin configuration, one <code>&lt;plugin&gt;</code> block in the profile with <code>&lt;inherited&gt;false&lt;/inherited&gt;</code> and the other in the main <code>&lt;build&gt;</code> block (outside of all profiles) without that, but it seems that <code>&lt;inherited&gt;false&lt;/inherited&gt;</code> is applied <em>after</em> plugin blocks are merged, not before.</p>
  <p>How can I control plugin inheritance by execution?</p>
  <hr />
  <p>I’ve got an idea, which is overly complicated and will cause quite some work, but which might do:</p>
  <ul>
  <li>move the parent POM into a second module</li>
  <li>make a new top-level POM which uses <code>&lt;relativePath&gt;parent/&lt;/relativePath&gt;</code> (instead of the implicit <code>&lt;relativePath&gt;../&lt;/relativePath&gt;</code>) to find its parent POM</li>
  <li>add only the <code>&lt;modules&gt;</code> from the old parent, and all plugin invocations that must not be inherited, to the top-level POM and remove them from the new parent module</li>
  <li>add <code>&lt;relativePath&gt;../parent/&lt;/relativePath&gt;</code> to the lib module’s POM make the it find its parent POM</li>
  </ul>
  <p>So this:</p>
  <ul>
  <li>toplevel/pom.xml (parent: <code>parent/pom.xml</code>; <code>&lt;module&gt;parent&lt;/module&gt; &lt;module&gt;lib&lt;/module&gt;</code>)</li>
  <li>toplevel/lib/pom.xml (parent: <code>../parent/pom.xml</code>)</li>
  <li>toplevel/parent/pom.xml (no parent)</li>
  </ul>
  <p>Does this look sound? It’s still quite somewhat backwards (especially as it will cause installation of the new top-level POM into Maven Central as well¹), so a better way to handle this is still welcome.</p>
  <p>① I might try either <a href="https://stackoverflow.com/a/60601955/2171120">this</a> trick or perhaps better <a href="https://stackoverflow.com/a/17627603/2171120">this</a> to avoid that… given that the new top-level POM is not referenced anywhere and doesn’t produce anything… oh well maybe it will… hmm… disentangling this looks like fun (which is why I’d prefer a less complex solution)</p>