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-jdeps-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 5baf85e  Prefer Guice injection (#19)
5baf85e is described below

commit 5baf85e72155f36867a1610d1c6dcc58309d02a9
Author: Elliotte Rusty Harold <elh...@users.noreply.github.com>
AuthorDate: Mon Dec 16 13:40:43 2024 +0000

    Prefer Guice injection (#19)
    
    * Prefer Guice injection
---
 pom.xml                                                           | 6 ++++++
 .../org/apache/maven/plugins/jdeps/AbstractJDKInternalsMojo.java  | 5 +++++
 .../java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java    | 8 +++++---
 .../java/org/apache/maven/plugins/jdeps/JDKInternalsMojo.java     | 8 ++++++++
 .../java/org/apache/maven/plugins/jdeps/TestJDKInternalsMojo.java | 8 ++++++++
 5 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index 7078493..b1f748b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,6 +78,12 @@ under the License.
       <artifactId>maven-plugin-annotations</artifactId>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+      <version>1</version>
+      <scope>provided</scope>
+    </dependency>
     <!-- Maven -->
     <dependency>
       <groupId>org.apache.maven</groupId>
diff --git 
a/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDKInternalsMojo.java 
b/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDKInternalsMojo.java
index 82007d8..62672b1 100644
--- a/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDKInternalsMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDKInternalsMojo.java
@@ -22,6 +22,7 @@ import java.nio.file.Path;
 import java.util.Set;
 
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.toolchain.ToolchainManager;
 import org.codehaus.plexus.util.cli.Commandline;
 
 /**
@@ -31,6 +32,10 @@ import org.codehaus.plexus.util.cli.Commandline;
  */
 public abstract class AbstractJDKInternalsMojo extends AbstractJDepsMojo {
 
+    protected AbstractJDKInternalsMojo(ToolchainManager toolchainManager) {
+        super(toolchainManager);
+    }
+
     @Override
     protected void addJDepsOptions(Commandline cmd, Set<Path> 
dependenciesToAnalyze) throws MojoFailureException {
         super.addJDepsOptions(cmd, dependenciesToAnalyze);
diff --git 
a/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java 
b/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java
index 82ce1c0..619cc55 100644
--- a/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java
@@ -43,7 +43,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.Parameter;
 import org.apache.maven.plugins.jdeps.consumers.JDepsConsumer;
 import org.apache.maven.project.MavenProject;
@@ -185,8 +184,11 @@ public abstract class AbstractJDepsMojo extends 
AbstractMojo {
     @Parameter(property = "jdeps.module")
     private String module;
 
-    @Component
-    private ToolchainManager toolchainManager;
+    private final ToolchainManager toolchainManager;
+
+    protected AbstractJDepsMojo(ToolchainManager toolchainManager) {
+        this.toolchainManager = toolchainManager;
+    }
 
     protected MavenProject getProject() {
         return project;
diff --git a/src/main/java/org/apache/maven/plugins/jdeps/JDKInternalsMojo.java 
b/src/main/java/org/apache/maven/plugins/jdeps/JDKInternalsMojo.java
index f2acd55..985351e 100644
--- a/src/main/java/org/apache/maven/plugins/jdeps/JDKInternalsMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jdeps/JDKInternalsMojo.java
@@ -18,6 +18,8 @@
  */
 package org.apache.maven.plugins.jdeps;
 
+import javax.inject.Inject;
+
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Collection;
@@ -28,6 +30,7 @@ import 
org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.toolchain.ToolchainManager;
 
 /**
  * Check if main classes depend on internal JDK classes
@@ -42,6 +45,11 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
         threadSafe = true)
 public class JDKInternalsMojo extends AbstractJDepsMojo {
 
+    @Inject
+    public JDKInternalsMojo(ToolchainManager toolchainManager) {
+        super(toolchainManager);
+    }
+
     @Override
     protected String getClassesDirectory() {
         return getProject().getBuild().getOutputDirectory();
diff --git 
a/src/main/java/org/apache/maven/plugins/jdeps/TestJDKInternalsMojo.java 
b/src/main/java/org/apache/maven/plugins/jdeps/TestJDKInternalsMojo.java
index 47e626f..06d6bb2 100644
--- a/src/main/java/org/apache/maven/plugins/jdeps/TestJDKInternalsMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jdeps/TestJDKInternalsMojo.java
@@ -18,6 +18,8 @@
  */
 package org.apache.maven.plugins.jdeps;
 
+import javax.inject.Inject;
+
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Collection;
@@ -29,6 +31,7 @@ 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.plugins.annotations.ResolutionScope;
+import org.apache.maven.toolchain.ToolchainManager;
 
 /**
  * Check if test classes depend on internal JDK classes
@@ -48,6 +51,11 @@ public class TestJDKInternalsMojo extends AbstractJDepsMojo {
     @Parameter(defaultValue = "true", property = "jdeps.test.failOnWarning")
     private boolean failOnWarning;
 
+    @Inject
+    public TestJDKInternalsMojo(ToolchainManager toolchainManager) {
+        super(toolchainManager);
+    }
+
     @Override
     protected boolean isFailOnWarning() {
         return failOnWarning;

Reply via email to