You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2022/07/21 21:37:43 UTC

[maven] branch maven-3.9.x updated: [MNG-7353] Add support for "mvn pluginPrefix:version:goal"

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch maven-3.9.x
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/maven-3.9.x by this push:
     new 95bdbf682 [MNG-7353] Add support for "mvn pluginPrefix:version:goal"
95bdbf682 is described below

commit 95bdbf6821d16c2b4f1df6f820600e0d4b1b9166
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sat Jun 18 23:41:13 2022 +0200

    [MNG-7353] Add support for "mvn pluginPrefix:version:goal"
    
    This closes #757
---
 .../DefaultLifecycleTaskSegmentCalculator.java     |  2 +-
 .../lifecycle/internal/MojoDescriptorCreator.java  | 37 +++++++++++++++-------
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleTaskSegmentCalculator.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleTaskSegmentCalculator.java
index cb49050c7..57dd0cc89 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleTaskSegmentCalculator.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleTaskSegmentCalculator.java
@@ -96,7 +96,7 @@ public class DefaultLifecycleTaskSegmentCalculator
         {
             if ( isGoalSpecification( task ) )
             {
-                // "pluginPrefix:goal" or "groupId:artifactId[:version]:goal"
+                // "pluginPrefix[:version]:goal" or "groupId:artifactId[:version]:goal"
 
                 lifecyclePluginResolver.resolveMissingPluginVersions( session.getTopLevelProject(), session );
 
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java
index edb8dceda..fda3dedb6 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java
@@ -176,18 +176,31 @@ public class MojoDescriptorCreator
         }
         else if ( numTokens == 3 )
         {
-            // We have everything that we need except the version
-            //
-            // org.apache.maven.plugins:maven-remote-resources-plugin:???:process
-            //
-            // groupId
-            // artifactId
-            // ???
-            // goal
-            //
-            plugin = new Plugin();
-            plugin.setGroupId( tok.nextToken() );
-            plugin.setArtifactId( tok.nextToken() );
+            // groupId:artifactId:goal or pluginPrefix:version:goal (since Maven 3.9.0)
+
+            String firstToken = tok.nextToken();
+            // groupId or pluginPrefix? heuristics: groupId contains dot (.) but not pluginPrefix
+            if ( firstToken.contains( "." ) )
+            {
+                // We have everything that we need except the version
+                //
+                // org.apache.maven.plugins:maven-remote-resources-plugin:???:process
+                //
+                // groupId
+                // artifactId
+                // ???
+                // goal
+                //
+                plugin = new Plugin();
+                plugin.setGroupId( firstToken );
+                plugin.setArtifactId( tok.nextToken() );
+            }
+            else
+            {
+                // pluginPrefix:version:goal, like remote-resources:3.5.0:process
+                plugin = findPluginForPrefix( firstToken, session );
+                plugin.setVersion( tok.nextToken() );
+            }
             goal = tok.nextToken();
         }
         else if ( numTokens <= 2 )