You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/12/29 18:38:02 UTC

(maven-plugin-tools) branch MPLUGIN-495 updated (81ba41bb -> 3d8c6eca)

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

michaelo pushed a change to branch MPLUGIN-495
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git


    from 81ba41bb [MPLUGIN-495] WARNINGs based on usage of @Component for MavenSession/MavenProject instead of @Parameter
     new 0be04c0d Prevent NPE
     new 3d8c6eca Remove deprecated code

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../EnhancedPluginDescriptorBuilder.java           |  8 ++++--
 .../maven/tools/plugin/util/PluginUtils.java       | 32 ----------------------
 2 files changed, 6 insertions(+), 34 deletions(-)


(maven-plugin-tools) 01/02: Prevent NPE

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MPLUGIN-495
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git

commit 0be04c0dd10886e223d50af32759b58c99d4e47c
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Fri Dec 29 19:37:44 2023 +0100

    Prevent NPE
---
 .../plugin/descriptor/EnhancedPluginDescriptorBuilder.java        | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/EnhancedPluginDescriptorBuilder.java b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/EnhancedPluginDescriptorBuilder.java
index c9e30570..6d3d2108 100644
--- a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/EnhancedPluginDescriptorBuilder.java
+++ b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/EnhancedPluginDescriptorBuilder.java
@@ -21,9 +21,11 @@ package org.apache.maven.plugins.plugin.descriptor;
 import java.io.Reader;
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
 import org.apache.maven.plugin.descriptor.Parameter;
@@ -87,7 +89,7 @@ public class EnhancedPluginDescriptorBuilder extends PluginDescriptorBuilder {
 
         PlexusConfiguration[] parameterConfigurations = c.getChild("parameters").getChildren("parameter");
 
-        List<Parameter> parameters = new ArrayList<>(mojoDescriptor.getParameters());
+        List<Parameter> parameters = new ArrayList<>(Optional.ofNullable(mojoDescriptor.getParameters()).orElseGet(Collections::emptyList));
         Map<String, Parameter> parameterMap = new LinkedHashMap<>(mojoDescriptor.getParameterMap());
 
         for (PlexusConfiguration d : parameterConfigurations) {
@@ -108,7 +110,9 @@ public class EnhancedPluginDescriptorBuilder extends PluginDescriptorBuilder {
         }
 
         // clear() is required for maven < 3.6.2
-        mojoDescriptor.getParameters().clear();
+        if (mojoDescriptor.getParameters() != null) {
+            mojoDescriptor.getParameters().clear();
+        }
         // set parameters
         mojoDescriptor.setParameters(parameters);
         // on maven < 3.6.2, getParameterMap is kept internally in a field


(maven-plugin-tools) 02/02: Remove deprecated code

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MPLUGIN-495
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git

commit 3d8c6eca64e502081f33c6ff2041af6c144e3fa6
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Fri Dec 29 19:37:57 2023 +0100

    Remove deprecated code
---
 .../maven/tools/plugin/util/PluginUtils.java       | 32 ----------------------
 1 file changed, 32 deletions(-)

diff --git a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java
index 4aa62ae7..98b764bb 100644
--- a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java
+++ b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java
@@ -25,9 +25,7 @@ import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
@@ -49,36 +47,6 @@ public final class PluginUtils {
         // nop
     }
 
-    /**
-     * Expression associated with class types to recognize Maven objects (injected in fact as parameters by <a
-     * href="/ref/current/maven-core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html">
-     * maven-core's PluginParameterExpressionEvaluator</a>) like components ("real" components are injected by Plexus).
-     *
-     * @deprecated wrong approach (fake components), documented parameter default values instead to learn people how to
-     *             discover them
-     */
-    @Deprecated
-    public static final Map<String, String> MAVEN_COMPONENTS;
-
-    static {
-        Map<String, String> mavenComponents = new HashMap<>();
-
-        mavenComponents.put("org.apache.maven.execution.MavenSession", "${session}");
-        mavenComponents.put("org.apache.maven.project.MavenProject", "${project}");
-        mavenComponents.put("org.apache.maven.plugin.MojoExecution", "${mojoExecution}");
-        mavenComponents.put("org.apache.maven.plugin.descriptor.PluginDescriptor", "${plugin}");
-        mavenComponents.put("org.apache.maven.settings.Settings", "${settings}");
-
-        mavenComponents.put("org.apache.maven.api.Session", "${session}");
-        mavenComponents.put("org.apache.maven.api.Project", "${project}");
-        mavenComponents.put("org.apache.maven.api.MojoExecution", "${mojoExecution}");
-        // TODO: apiv4: add PluginDescriptor to the api ?
-        // mavenComponents.put( "org.apache.maven.api.descriptor.PluginDescriptor", "${plugin}" );
-        mavenComponents.put("org.apache.maven.api.settings.Settings", "${settings}");
-
-        MAVEN_COMPONENTS = Collections.unmodifiableMap(mavenComponents);
-    }
-
     /**
      * @param basedir not null
      * @param include not null