[ 
https://issues.apache.org/jira/browse/MNG-6562?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17156049#comment-17156049
 ] 

Michael Osipov commented on MNG-6562:
-------------------------------------

Folks, I have a problem with the following change:
{noformat}
--- 
a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java
+++ 
b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java
@@ -56,6 +56,8 @@
 public class DefaultLifecyclePluginAnalyzer
     implements LifeCyclePluginAnalyzer
 {
+    public static final String DEFAULTLIFECYCLEBINDINGS_MODELID = 
"org.apache.maven:maven-core:"
+        + 
DefaultLifecyclePluginAnalyzer.class.getPackage().getImplementationVersion() + 
":default-lifecycle-bindings";

     @Requirement( role = LifecycleMapping.class )
     private Map<String, LifecycleMapping> lifecycleMappings;
@@ -143,10 +145,8 @@ else if ( lifecycle.getDefaultLifecyclePhases() != null )

     private void parseLifecyclePhaseDefinitions( Map<Plugin, Plugin> plugins, 
String phase, LifecyclePhase goals )
     {
-        String modelId = "org.apache.maven:maven-core:" + 
this.getClass().getPackage().getImplementationVersion()
-            + ":default-lifecycle-bindings";
         InputSource inputSource = new InputSource();
-        inputSource.setModelId( modelId );
+        inputSource.setModelId( DEFAULTLIFECYCLEBINDINGS_MODELID );
         InputLocation location = new InputLocation( -1, -1, inputSource );
         location.setLocation( 0, location );
{noformat}

As documented in MNG-6932 this can lead to issues when the package is not 
defined. I intended to replace this in MNG-6960 with 
{{RuntimeInformation#getMavenVersion()}}, but that is not possible anymore. 
Moreover, this leaks abstraction. We do use interfaces to hide implementations, 
but create stuff like 
{{DefaultLifecyclePluginAnalyzer#DEFAULTLIFECYCLEBINDINGS_MODELID}}. Seriously? 
The interface should have a method {{#getModelId()}} which should be used 
instead of this.
Do you see any chance to use a injected {{LifecyclePluginAnalyzer}} in 
{{org.apache.maven.lifecycle.internal.builder.BuilderCommon.resolveBuildPlan(MavenSession,
 MavenProject, TaskSegment, Set<Artifact>)}} to resolve this issue? Otherwise 
I'd need to close both MNG-6960 and MNG-6932.

> WARN if plugins injected by default lifecycle bindings don't have their 
> version locked in pom.xml or parent
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: MNG-6562
>                 URL: https://issues.apache.org/jira/browse/MNG-6562
>             Project: Maven
>          Issue Type: Improvement
>          Components: Plugins and Lifecycle
>    Affects Versions: 3.6.0
>            Reporter: Herve Boutemy
>            Assignee: Robert Scholte
>            Priority: Major
>             Fix For: 3.7.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Currently, when building from a basic pom.xml:
> {code:xml}<project>
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>com.mycompany.app</groupId>
>   <artifactId>my-app</artifactId>
>   <version>1.0-SNAPSHOT</version>
> </project>{code}
> many plugins are used, but their version is not locked by the user: the 
> default plugins versions depend on Maven version used, which is not stable 
> over different Maven versions.
> Adding a warning for this stability issue will help users know that they need 
> to lock down plugins versions in their pom (or parent), something like:
> {noformat}[WARNING] 
> [WARNING] Some problems were encountered while building the effective model 
> for com.mycompany.app:my-app:jar:1.0-SNAPSHOT
> [WARNING] Version not locked for default bindings plugins 
> [maven-install-plugin, maven-resources-plugin, maven-surefire-plugin, 
> maven-compiler-plugin, maven-jar-plugin, maven-deploy-plugin, 
> maven-site-plugin], you should define versions in pluginManagement section of 
> your pom.xml or parent
> [WARNING] 
> [WARNING] It is highly recommended to fix these problems because they 
> threaten the stability of your build.
> [WARNING] 
> [WARNING] For this reason, future Maven versions might no longer support 
> building such malformed projects.{noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to