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

ASF GitHub Bot commented on MPLUGIN-519:
----------------------------------------

cstamas commented on code in PR #280:
URL: 
https://github.com/apache/maven-plugin-tools/pull/280#discussion_r1602074186


##########
maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/AddPluginArtifactMetadataMojo.java:
##########
@@ -69,25 +69,33 @@ public class AddPluginArtifactMetadataMojo extends 
AbstractMojo {
     @Parameter(defaultValue = "false", property = "maven.plugin.skip")
     private boolean skip;
 
+    @Component
+    private RuntimeInformation runtimeInformation;
+
+    private final VersionScheme versionScheme = new GenericVersionScheme();
+
     /** {@inheritDoc} */
     @Override
     public void execute() throws MojoExecutionException {
         if (skip) {
             getLog().warn("Execution skipped");
             return;
         }
-        Artifact projectArtifact = project.getArtifact();
-
-        Versioning versioning = new Versioning();
-        versioning.setLatest(projectArtifact.getVersion());
-        versioning.updateTimestamp();
-        ArtifactRepositoryMetadata metadata = new 
ArtifactRepositoryMetadata(projectArtifact, versioning);
-        projectArtifact.addMetadata(metadata);
-
-        GroupRepositoryMetadata groupMetadata = new 
GroupRepositoryMetadata(project.getGroupId());
-        groupMetadata.addPluginMapping(getGoalPrefix(), 
project.getArtifactId(), project.getName());
+        // nothing if Maven is 3.9+
+        try {
+            if (versionScheme
+                            .parseVersion("3.9.0")
+                            
.compareTo(versionScheme.parseVersion(runtimeInformation.getMavenVersion()))
+                    < 1) {
+                getLog().info("This Mojo is not used in Maven version 3.9.0 
and above");
+                return;
+            }
+        } catch (InvalidVersionSpecificationException e) {
+            // not happening with generic
+            throw new MojoExecutionException(e);
+        }
 
-        projectArtifact.addMetadata(groupMetadata);
+        LegacySupport.execute(project, getGoalPrefix());

Review Comment:
   This change is unrelated. What happened is that those users had no prefix 
set (ever), so remote metadata has no prefix either, and now that they 
upgraded, and forced to set plugin prefix (in latest m-p-p), NPE happens.





> Update to Parent POM 42, prerequisite 3.6.3
> -------------------------------------------
>
>                 Key: MPLUGIN-519
>                 URL: https://issues.apache.org/jira/browse/MPLUGIN-519
>             Project: Maven Plugin Tools
>          Issue Type: Dependency upgrade
>            Reporter: Tamas Cservenak
>            Assignee: Tamas Cservenak
>            Priority: Major
>             Fix For: 3.13.0
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to