<div dir="ltr"><div><div><div><div><div><div>Hello all,<br><br></div>I recently contributed to the forge project (FORGE-842) by adding the pluginManagement support to the mavenPluginFacet.<br></div><br></div>One question is still opened, which is the purpose of this post.<br>
</div>Basically, it is about a smart plugin resolution, ie having the plugin properties (artifactId, groupId, version,...) automatically resolved when a plugin is defined in a &quot;pluginManagement&quot; section and used in a &quot;plugins&quot; section.<br>
</div>Let&#39;s take the following example:<br><br><pre class=""><span class="">&lt;build&gt;</span>
    <span class="">&lt;pluginManagement&gt;</span>
      <span class="">&lt;plugins&gt;</span>
        <span class="">&lt;plugin&gt;</span>
                <span class="">&lt;artifactId&gt;</span>maven-compiler-plugin<span class="">&lt;/artifactId&gt;</span>
                <span class="">&lt;version&gt;</span>2.0.2<span class="">&lt;/version&gt;</span>
                <span class="">&lt;configuration&gt;</span>
                  <span class="">&lt;source&gt;</span>1.6<span class="">&lt;/source&gt;</span>
                  <span class="">&lt;target&gt;</span>1.6<span class="">&lt;/target&gt;</span>
                <span class="">&lt;/configuration&gt;</span>
            <span class="">&lt;/plugin&gt;</span>
      <span class="">&lt;/plugins&gt;</span>
    <span class="">&lt;/pluginManagement&gt;</span>
    <span class="">&lt;plugins&gt;</span>
      <span class="">&lt;plugin&gt;</span>
        <span class="">&lt;artifactId&gt;</span>maven-compiler-plugin<span class="">&lt;/artifactId&gt;</span>
      <span class="">&lt;/plugin&gt;</span>
    <span class="">&lt;/plugins&gt;</span>
<span class="">&lt;/build&gt;</span></pre><br></div>Currently, a call to the <br><div class="" style="border-width:1px"><div class="">
<pre class="">mavenPluginFacet.getPlugin(DependencyBuilder.create(<span class="">&quot;org.apache.maven.plugins:maven-compiler-plugin&quot;</span>)).getVersion()</pre>
will return a null value, because the version is not declared in the &quot;//build/plugins/plugin&quot; section.<br></div><div class="">Maven will, however, resolve the plugin by using the version and configuration of the maven-compiler-plugin declared in the &quot;//build/pluginManagement/plugins&quot; section.<br>
</div><div class="">Moreover, we should also note that the pluginManagement section will be, most of the time, declared in the parent pom, which makes the smart resolution as follow:<br></div><div class="">1. Compute the effective pom<br>
</div><div class="">2. Resolve the plugin properties<br><br></div><div class="">My question is: based on the fact that similar implementation was done with Dependency and DependencyManagement sections (in the MavenDependencyFacet and DependencyInstaller), which methods should be implemented ?<br>
<br></div><div class="">Following the same logic, we could also thing of a smart &quot;addPlugin&quot; method: what if I add a plugin that is already managed, with the same version of the managed plugin ? With some configuration element(s) being the same as the managed plugin ? ...<br>
<br></div><div class="">Based on your answers, I will create a FORGE issue and will try to implement the missing methods.<br><br></div><div class="">Thanks,<br></div><div class="">Charles.<br></div><div class=""><br></div>
<div class=""><br><br><br></div></div> </div>