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

elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new f14438f8 Convert more Mojos from Plexus to Guice (#480)
f14438f8 is described below

commit f14438f888266c7f543cc144a5bfb12b2208bc9b
Author: Elliotte Rusty Harold <elh...@users.noreply.github.com>
AuthorDate: Tue Nov 19 12:36:25 2024 +0000

    Convert more Mojos from Plexus to Guice (#480)
    
    * [MDEP-966] Convert more Mojos from PLexus to Guice
---
 .../apache/maven/plugins/dependency/GetMojo.java   | 28 ++++++----
 .../maven/plugins/dependency/PropertiesMojo.java   |  9 ++-
 .../dependency/PurgeLocalRepositoryMojo.java       | 64 +++++++++++++---------
 3 files changed, 62 insertions(+), 39 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java 
b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java
index 85e0cd10..889f8647 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java
@@ -18,6 +18,8 @@
  */
 package org.apache.maven.plugins.dependency;
 
+import javax.inject.Inject;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -34,7 +36,6 @@ import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.DefaultProjectBuildingRequest;
@@ -58,28 +59,22 @@ import 
org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverE
 public class GetMojo extends AbstractMojo {
     private static final Pattern ALT_REPO_SYNTAX_PATTERN = 
Pattern.compile("(.+)::(.*)::(.+)");
 
-    @Component
     private MavenSession session;
 
-    @Component
     private ArtifactResolver artifactResolver;
 
-    @Component
     private DependencyResolver dependencyResolver;
 
-    @Component
     private ArtifactHandlerManager artifactHandlerManager;
 
     /**
      * Map that contains the layouts.
      */
-    @Component(role = ArtifactRepositoryLayout.class)
     private Map<String, ArtifactRepositoryLayout> repositoryLayouts;
 
     /**
      * The repository system.
      */
-    @Component
     private RepositorySystem repositorySystem;
 
     private DefaultDependableCoordinate coordinate = new 
DefaultDependableCoordinate();
@@ -97,9 +92,6 @@ public class GetMojo extends AbstractMojo {
     @Parameter(property = "artifact")
     private String artifact;
 
-    /**
-     *
-     */
     @Parameter(defaultValue = "${project.remoteArtifactRepositories}", 
readonly = true, required = true)
     private List<ArtifactRepository> pomRemoteRepositories;
 
@@ -117,6 +109,22 @@ public class GetMojo extends AbstractMojo {
     @Parameter(property = "mdep.skip", defaultValue = "false")
     private boolean skip;
 
+    @Inject
+    public GetMojo(
+            MavenSession session,
+            ArtifactResolver artifactResolver,
+            DependencyResolver dependencyResolver,
+            ArtifactHandlerManager artifactHandlerManager,
+            Map<String, ArtifactRepositoryLayout> repositoryLayouts,
+            RepositorySystem repositorySystem) {
+        this.session = session;
+        this.artifactResolver = artifactResolver;
+        this.dependencyResolver = dependencyResolver;
+        this.artifactHandlerManager = artifactHandlerManager;
+        this.repositoryLayouts = repositoryLayouts;
+        this.repositorySystem = repositorySystem;
+    }
+
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
         if (isSkip()) {
diff --git 
a/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java 
b/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java
index 4eed301d..1e12505a 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java
@@ -18,12 +18,13 @@
  */
 package org.apache.maven.plugins.dependency;
 
+import javax.inject.Inject;
+
 import java.util.Set;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
@@ -50,9 +51,13 @@ public class PropertiesMojo extends AbstractMojo {
     /**
      * The current Maven project
      */
-    @Component
     private MavenProject project;
 
+    @Inject
+    public PropertiesMojo(MavenProject project) {
+        this.project = project;
+    }
+
     /**
      * Skip plugin execution completely.
      *
diff --git 
a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java
 
b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java
index c678faf4..827a0e8a 100644
--- 
a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java
+++ 
b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java
@@ -18,6 +18,8 @@
  */
 package org.apache.maven.plugins.dependency;
 
+import javax.inject.Inject;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -40,7 +42,6 @@ import org.apache.maven.plugin.MojoExecution;
 import org.apache.maven.plugin.MojoExecution.Source;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
@@ -79,32 +80,39 @@ public class PurgeLocalRepositoryMojo extends AbstractMojo {
 
     private static final String GROUP_ID_FUZZINESS = "groupId";
 
-    /**
-     * The Maven projects in the reactor.
-     */
-    @Parameter(defaultValue = "${reactorProjects}", readonly = true, required 
= true)
-    private List<MavenProject> reactorProjects;
-
     /**
      * The current Maven project.
      */
-    @Component
     private MavenProject project;
 
-    @Component
     private MavenSession session;
 
     /**
-     * This mojo execution, used to determine if it was launched from the 
lifecycle or the command-line.
+     * Artifact handler manager.
      */
-    @Parameter(defaultValue = "${mojo}", required = true, readonly = true)
-    private MojoExecution mojoExecution;
+    private ArtifactHandlerManager artifactHandlerManager;
 
     /**
-     * Artifact handler manager.
+     * The dependency resolver
      */
-    @Component
-    private ArtifactHandlerManager artifactHandlerManager;
+    private DependencyResolver dependencyResolver;
+
+    /**
+     * The artifact resolver used to re-resolve dependencies, if that option 
is enabled.
+     */
+    private ArtifactResolver artifactResolver;
+
+    /**
+     * The Maven projects in the reactor.
+     */
+    @Parameter(defaultValue = "${reactorProjects}", readonly = true, required 
= true)
+    private List<MavenProject> reactorProjects;
+
+    /**
+     * This mojo execution, used to determine if it was launched from the 
lifecycle or the command-line.
+     */
+    @Parameter(defaultValue = "${mojo}", required = true, readonly = true)
+    private MojoExecution mojoExecution;
 
     /**
      * The list of dependencies in the form of groupId:artifactId which should 
BE deleted/purged from the local
@@ -172,18 +180,6 @@ public class PurgeLocalRepositoryMojo extends AbstractMojo 
{
     @Parameter(defaultValue = "${localRepository}", readonly = true, required 
= true)
     private ArtifactRepository localRepository;
 
-    /**
-     * The dependency resolver
-     */
-    @Component
-    private DependencyResolver dependencyResolver;
-
-    /**
-     * The artifact resolver used to re-resolve dependencies, if that option 
is enabled.
-     */
-    @Component
-    private ArtifactResolver artifactResolver;
-
     /**
      * Determines how liberally the plugin will delete an artifact from the 
local repository. Values are: <br/>
      * <ul>
@@ -224,6 +220,20 @@ public class PurgeLocalRepositoryMojo extends AbstractMojo 
{
     @Parameter(property = "skip", defaultValue = "false")
     private boolean skip;
 
+    @Inject
+    public PurgeLocalRepositoryMojo(
+            MavenProject project,
+            MavenSession session,
+            ArtifactHandlerManager artifactHandlerManager,
+            DependencyResolver dependencyResolver,
+            ArtifactResolver artifactResolver) {
+        this.session = session;
+        this.project = project;
+        this.artifactHandlerManager = artifactHandlerManager;
+        this.dependencyResolver = dependencyResolver;
+        this.artifactResolver = artifactResolver;
+    }
+
     /**
      * Includes only direct project dependencies.
      */

Reply via email to