<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 "pluginManagement" section and used in a "plugins" section.<br>
</div>Let's take the following example:<br><br><pre class=""><span class=""><build></span>
<span class=""><pluginManagement></span>
<span class=""><plugins></span>
<span class=""><plugin></span>
         <span class=""><artifactId></span>maven-compiler-plugin<span class=""></artifactId></span>
         <span class=""><version></span>2.0.2<span class=""></version></span>
         <span class=""><configuration></span>
         <span class=""><source></span>1.6<span class=""></source></span>
         <span class=""><target></span>1.6<span class=""></target></span>
         <span class=""></configuration></span>
         <span class=""></plugin></span>
<span class=""></plugins></span>
<span class=""></pluginManagement></span>
<span class=""><plugins></span>
<span class=""><plugin></span>
<span class=""><artifactId></span>maven-compiler-plugin<span class=""></artifactId></span>
<span class=""></plugin></span>
<span class=""></plugins></span>
<span class=""></build></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="">"org.apache.maven.plugins:maven-compiler-plugin"</span>)).getVersion()</pre>
will return a null value, because the version is not declared in the "//build/plugins/plugin" 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 "//build/pluginManagement/plugins" 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 "addPlugin" 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>