slawekjaranowski commented on code in PR #280: URL: https://github.com/apache/maven-plugin-tools/pull/280#discussion_r1586636233
########## 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: We will see how many people use nexus-staging -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org