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-resolver.git


The following commit(s) were added to refs/heads/master by this push:
     new 1c580b01 Prefer Guice injection in sample (#628)
1c580b01 is described below

commit 1c580b0165e73492e7cf23a88f548056e07e2559
Author: Elliotte Rusty Harold <elh...@users.noreply.github.com>
AuthorDate: Mon Dec 16 11:38:01 2024 +0000

    Prefer Guice injection in sample (#628)
    
    * Prefer Guice injection in sample
---
 .../maven-resolver-demo-maven-plugin/pom.xml           |  5 +++++
 .../resolver/examples/maven/ResolveArtifactMojo.java   | 18 ++++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml 
b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml
index 5c3bfb19..8097bd3d 100644
--- a/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml
+++ b/maven-resolver-demos/maven-resolver-demo-maven-plugin/pom.xml
@@ -72,6 +72,11 @@
       <artifactId>slf4j-api</artifactId>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+      <scope>compile</scope>
+    </dependency>
   </dependencies>
 
   <profiles>
diff --git 
a/maven-resolver-demos/maven-resolver-demo-maven-plugin/src/main/java/org/apache/maven/resolver/examples/maven/ResolveArtifactMojo.java
 
b/maven-resolver-demos/maven-resolver-demo-maven-plugin/src/main/java/org/apache/maven/resolver/examples/maven/ResolveArtifactMojo.java
index 3d157be5..b1053fe4 100644
--- 
a/maven-resolver-demos/maven-resolver-demo-maven-plugin/src/main/java/org/apache/maven/resolver/examples/maven/ResolveArtifactMojo.java
+++ 
b/maven-resolver-demos/maven-resolver-demo-maven-plugin/src/main/java/org/apache/maven/resolver/examples/maven/ResolveArtifactMojo.java
@@ -18,12 +18,13 @@
  */
 package org.apache.maven.resolver.examples.maven;
 
+import javax.inject.Inject;
+
 import java.util.List;
 
 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.eclipse.aether.RepositorySystem;
@@ -43,11 +44,6 @@ import org.slf4j.LoggerFactory;
 @Mojo(name = "resolve-artifact", threadSafe = true)
 public class ResolveArtifactMojo extends AbstractMojo {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(ResolveArtifactMojo.class);
-    /**
-     * The entry point to Maven Artifact Resolver, i.e. the component doing 
all the work.
-     */
-    @Component
-    private RepositorySystem repoSystem;
 
     /**
      * The current repository/network configuration of Maven.
@@ -67,6 +63,16 @@ public class ResolveArtifactMojo extends AbstractMojo {
     @Parameter(property = "resolver.artifactCoords", readonly = true)
     private String artifactCoords;
 
+    /**
+     * The entry point to Maven Artifact Resolver; that is, the component 
doing all the work.
+     */
+    private final RepositorySystem repoSystem;
+
+    @Inject
+    public ResolveArtifactMojo(RepositorySystem repoSystem) {
+        this.repoSystem = repoSystem;
+    }
+
     /**
      * The actual execution of the mojo.
      */

Reply via email to