You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2024/12/30 17:13:23 UTC
(maven-dependency-plugin) branch MDEP-966 created (now 6e89b28c)
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a change to branch MDEP-966
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git
at 6e89b28c Convert Analyze Mojos to Guice constructor injection
This branch includes the following new commits:
new 6e89b28c Convert Analyze Mojos to Guice constructor injection
The 1 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.
(maven-dependency-plugin) 01/01: Convert Analyze Mojos to Guice constructor injection
Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch MDEP-966
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git
commit 6e89b28ca760446437dd6616239190ba0ef10281
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Mon Dec 30 12:13:02 2024 -0500
Convert Analyze Mojos to Guice constructor injection
---
.../dependency/analyze/AbstractAnalyzeMojo.java | 30 ++++++++++++----------
.../plugins/dependency/analyze/AnalyzeMojo.java | 15 ++++++++---
.../dependency/analyze/AnalyzeOnlyMojo.java | 11 +++++++-
3 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java
index 05b9cb3c..765b334b 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java
@@ -34,7 +34,6 @@ import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
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.project.MavenProject;
import org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter;
@@ -55,19 +54,6 @@ import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
public abstract class AbstractAnalyzeMojo extends AbstractMojo {
// fields -----------------------------------------------------------------
- /**
- * The plexusContainer to look-up the right {@link ProjectDependencyAnalyzer} implementation depending on the mojo
- * configuration.
- */
- @Component
- private PlexusContainer plexusContainer;
-
- /**
- * The Maven project to analyze.
- */
- @Component
- private MavenProject project;
-
/**
* Specify the project dependency analyzer to use (plexus component role-hint). By default,
* <a href="/shared/maven-dependency-analyzer/">maven-dependency-analyzer</a> is used. To use this, you must declare
@@ -271,6 +257,22 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo {
@Parameter(property = "mdep.analyze.excludedClasses")
private Set<String> excludedClasses;
+ /**
+ * The plexusContainer to look up the {@link ProjectDependencyAnalyzer} implementation depending on the mojo
+ * configuration.
+ */
+ private final PlexusContainer plexusContainer;
+
+ /**
+ * The Maven project to analyze.
+ */
+ private final MavenProject project;
+
+ protected AbstractAnalyzeMojo(PlexusContainer plexusContainer, MavenProject project) {
+ this.plexusContainer = plexusContainer;
+ this.project = project;
+ }
+
// Mojo methods -----------------------------------------------------------
/*
diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeMojo.java
index 84907bb6..1cab8753 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeMojo.java
@@ -18,17 +18,21 @@
*/
package org.apache.maven.plugins.dependency.analyze;
+import javax.inject.Inject;
+
import org.apache.maven.plugins.annotations.Execute;
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.project.MavenProject;
+import org.codehaus.plexus.PlexusContainer;
/**
* Analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused
- * and declared. This goal is intended to be used standalone, thus it always executes the <code>test-compile</code>
- * phase - use the <code>dependency:analyze-only</code> goal instead when participating in the build lifecycle.
+ * and declared. This goal is intended to be used standalone. Thus, it always executes the <code>test-compile</code>
+ * phase. Use the <code>dependency:analyze-only</code> goal instead when participating in the build lifecycle.
* <p>
- * By default, <a href="http://maven.apache.org/shared/maven-dependency-analyzer/">maven-dependency-analyzer</a> is used
+ * By default, <a href="https://maven.apache.org/shared/maven-dependency-analyzer/">maven-dependency-analyzer</a> is used
* to perform the analysis, with limitations due to the fact that it works at bytecode level, but any analyzer can be
* plugged in through <code>analyzer</code> parameter.
* </p>
@@ -41,4 +45,9 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
@Execute(phase = LifecyclePhase.TEST_COMPILE)
public class AnalyzeMojo extends AbstractAnalyzeMojo {
// subclassed to provide annotations
+
+ @Inject
+ public AnalyzeMojo(PlexusContainer plexusContainer, MavenProject project) {
+ super(plexusContainer, project);
+ }
}
diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeOnlyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeOnlyMojo.java
index 43d1e302..ba7d0ddd 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeOnlyMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeOnlyMojo.java
@@ -18,9 +18,13 @@
*/
package org.apache.maven.plugins.dependency.analyze;
+import javax.inject.Inject;
+
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.project.MavenProject;
+import org.codehaus.plexus.PlexusContainer;
/**
* Analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused
@@ -28,7 +32,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
* <code>test-compile</code> phase has been executed - use the <code>dependency:analyze</code> goal instead when running
* standalone.
* <p>
- * By default, <a href="http://maven.apache.org/shared/maven-dependency-analyzer/">maven-dependency-analyzer</a> is used
+ * By default, <a href="https://maven.apache.org/shared/maven-dependency-analyzer/">maven-dependency-analyzer</a> is used
* to perform the analysis, with limitations due to the fact that it works at bytecode level, but any analyzer can be
* plugged in through <code>analyzer</code> parameter.
* </p>
@@ -46,4 +50,9 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
// @formatter:on
public class AnalyzeOnlyMojo extends AbstractAnalyzeMojo {
// subclassed to provide annotations
+
+ @Inject
+ public AnalyzeOnlyMojo(PlexusContainer plexusContainer, MavenProject project) {
+ super(plexusContainer, project);
+ }
}