From c849888b5f21ed2784d662bc84a63077ecacad06 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 3 May 2025 10:59:53 +0200 Subject: [PATCH] [MNG-8717] Remove maven-plugin-plugin:addPluginArtifactMetadata from default binding --- .../MavenPluginLifecycleMappingProvider.java | 5 +- .../lifecycle/LifecycleExecutorTest.java | 4 +- .../it/MavenIT0138PluginLifecycleTest.java | 4 - .../coreit/AddPluginArtifactMetadataMojo.java | 84 ------------------- .../plugin/coreit/UpdateRegistryMojo.java | 84 ------------------- 5 files changed, 2 insertions(+), 179 deletions(-) delete mode 100644 its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/coreit/AddPluginArtifactMetadataMojo.java delete mode 100644 its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/coreit/UpdateRegistryMojo.java diff --git a/impl/maven-core/src/main/java/org/apache/maven/lifecycle/providers/packaging/MavenPluginLifecycleMappingProvider.java b/impl/maven-core/src/main/java/org/apache/maven/lifecycle/providers/packaging/MavenPluginLifecycleMappingProvider.java index 9315c50793ae..425e8e337561 100644 --- a/impl/maven-core/src/main/java/org/apache/maven/lifecycle/providers/packaging/MavenPluginLifecycleMappingProvider.java +++ b/impl/maven-core/src/main/java/org/apache/maven/lifecycle/providers/packaging/MavenPluginLifecycleMappingProvider.java @@ -38,10 +38,7 @@ public final class MavenPluginLifecycleMappingProvider extends AbstractLifecycle "org.apache.maven.plugins:maven-resources-plugin:" + RESOURCES_PLUGIN_VERSION + ":testResources", "test-compile", "org.apache.maven.plugins:maven-compiler-plugin:" + COMPILER_PLUGIN_VERSION + ":testCompile", "test", "org.apache.maven.plugins:maven-surefire-plugin:" + SUREFIRE_PLUGIN_VERSION + ":test", - "package", - "org.apache.maven.plugins:maven-jar-plugin:" + JAR_PLUGIN_VERSION + ":jar," - + "org.apache.maven.plugins:maven-plugin-plugin:" + PLUGIN_PLUGIN_VERSION - + ":addPluginArtifactMetadata", + "package", "org.apache.maven.plugins:maven-jar-plugin:" + JAR_PLUGIN_VERSION + ":jar,", "install", "org.apache.maven.plugins:maven-install-plugin:" + INSTALL_PLUGIN_VERSION + ":install", "deploy", "org.apache.maven.plugins:maven-deploy-plugin:" + DEPLOY_PLUGIN_VERSION + ":deploy" }; diff --git a/impl/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java b/impl/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java index ca7a81f0bff0..800d4bf59924 100644 --- a/impl/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java +++ b/impl/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java @@ -217,8 +217,7 @@ public void testCalculationOfBuildPlanWithMultipleExecutionsOfModello() throws E // [12] compiler:testCompile // [13] surefire:test // [14] jar:jar - // [15] plugin:addPluginArtifactMetadata - // [16] install:install + // [15] install:install // assertListEquals( @@ -237,7 +236,6 @@ public void testCalculationOfBuildPlanWithMultipleExecutionsOfModello() throws E "compiler:testCompile", "surefire:test", "jar:jar", - "plugin:addPluginArtifactMetadata", "install:install"), executions.stream() .map(execution -> execution.getMojoDescriptor().getFullGoalName()) diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0138PluginLifecycleTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0138PluginLifecycleTest.java index 22e9d10ba678..26913187d718 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0138PluginLifecycleTest.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0138PluginLifecycleTest.java @@ -54,11 +54,7 @@ public void testit0138() throws Exception { verifier.verifyFilePresent("target/compiler-test-compile.txt"); verifier.verifyFilePresent("target/surefire-test.txt"); verifier.verifyFilePresent("target/jar-jar.txt"); - verifier.verifyFilePresent("target/plugin-add-plugin-artifact-metadata.txt"); verifier.verifyFilePresent("target/install-install.txt"); - if (matchesVersionRange("(,2.2.0)")) { - verifier.verifyFilePresent("target/plugin-update-registry.txt"); - } verifier.verifyFilePresent("target/deploy-deploy.txt"); verifier.verifyErrorFreeLog(); } diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/coreit/AddPluginArtifactMetadataMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/coreit/AddPluginArtifactMetadataMojo.java deleted file mode 100644 index a054cd90f969..000000000000 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/coreit/AddPluginArtifactMetadataMojo.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.plugin.coreit; - -import java.io.File; -import java.io.IOException; - -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; - -/** - * Creates a text file in the project base directory. - * - * - * @author Benjamin Bentmann - * - */ -@Mojo(name = "addPluginArtifactMetadata", defaultPhase = LifecyclePhase.PACKAGE) -public class AddPluginArtifactMetadataMojo extends AbstractMojo { - - /** - * The current Maven project. - */ - @Parameter(defaultValue = "${project}", required = true, readonly = true) - private MavenProject project; - - /** - * The path to the output file, relative to the project base directory. - * - */ - @Parameter - private String pathname = "target/plugin-add-plugin-artifact-metadata.txt"; - - /** - * Runs this mojo. - * - * @throws MojoExecutionException If the output file could not be created. - * @throws MojoFailureException If the output file has not been set. - */ - public void execute() throws MojoExecutionException, MojoFailureException { - getLog().info("[MAVEN-CORE-IT-LOG] Using output file path: " + pathname); - - if (pathname == null || pathname.length() <= 0) { - throw new MojoFailureException("Path name for output file has not been specified"); - } - - File outputFile = new File(pathname); - if (!outputFile.isAbsolute()) { - outputFile = new File(project.getBasedir(), pathname).getAbsoluteFile(); - } - - getLog().info("[MAVEN-CORE-IT-LOG] Creating output file: " + outputFile); - - try { - outputFile.getParentFile().mkdirs(); - outputFile.createNewFile(); - } catch (IOException e) { - throw new MojoExecutionException("Output file could not be created: " + pathname, e); - } - - getLog().info("[MAVEN-CORE-IT-LOG] Created output file: " + outputFile); - } -} diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/coreit/UpdateRegistryMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/coreit/UpdateRegistryMojo.java deleted file mode 100644 index 699d7440bf49..000000000000 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/coreit/UpdateRegistryMojo.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.plugin.coreit; - -import java.io.File; -import java.io.IOException; - -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; - -/** - * Creates a text file in the project base directory. - * - * - * @author Benjamin Bentmann - * - */ -@Mojo(name = "updateRegistry", defaultPhase = LifecyclePhase.INSTALL) -public class UpdateRegistryMojo extends AbstractMojo { - - /** - * The current Maven project. - */ - @Parameter(defaultValue = "${project}", required = true, readonly = true) - private MavenProject project; - - /** - * The path to the output file, relative to the project base directory. - * - */ - @Parameter - private String pathname = "target/plugin-update-registry.txt"; - - /** - * Runs this mojo. - * - * @throws MojoExecutionException If the output file could not be created. - * @throws MojoFailureException If the output file has not been set. - */ - public void execute() throws MojoExecutionException, MojoFailureException { - getLog().info("[MAVEN-CORE-IT-LOG] Using output file path: " + pathname); - - if (pathname == null || pathname.length() <= 0) { - throw new MojoFailureException("Path name for output file has not been specified"); - } - - File outputFile = new File(pathname); - if (!outputFile.isAbsolute()) { - outputFile = new File(project.getBasedir(), pathname).getAbsoluteFile(); - } - - getLog().info("[MAVEN-CORE-IT-LOG] Creating output file: " + outputFile); - - try { - outputFile.getParentFile().mkdirs(); - outputFile.createNewFile(); - } catch (IOException e) { - throw new MojoExecutionException("Output file could not be created: " + pathname, e); - } - - getLog().info("[MAVEN-CORE-IT-LOG] Created output file: " + outputFile); - } -}