This is an automated email from the ASF dual-hosted git repository. elharo pushed a commit to branch abstract in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git
commit 69fe095acafd010f72e40f605a8d865885afafa6 Author: Elliotte Rusty Harold <elh...@ibiblio.org> AuthorDate: Thu Nov 28 10:56:34 2024 -0500 Convert AbstractAnalyzeMojo to Guice --- .../dependency/analyze/AbstractAnalyzeMojo.java | 31 +++++++++++----------- .../plugins/dependency/analyze/AnalyzeMojo.java | 11 +++++++- .../dependency/analyze/AnalyzeOnlyMojo.java | 9 +++++++ 3 files changed, 35 insertions(+), 16 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..eeb1e90c 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; @@ -54,20 +53,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 +256,22 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { @Parameter(property = "mdep.analyze.excludedClasses") private Set<String> excludedClasses; + /** + * The plexusContainer to look-up the right {@link ProjectDependencyAnalyzer} implementation depending on the mojo + * configuration. + */ + private PlexusContainer plexusContainer; + + /** + * The Maven project to analyze. + */ + private MavenProject project; + + public 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..c6e9ca7f 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. * <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..6dab02c0 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 @@ -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); + } }