This is an automated email from the ASF dual-hosted git repository. elharo pushed a commit to branch guice in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git
The following commit(s) were added to refs/heads/guice by this push: new 05cbbcf1 pom 05cbbcf1 is described below commit 05cbbcf12507f4690027361833617f1c71d7eb69 Author: Elliotte Rusty Harold <elh...@ibiblio.org> AuthorDate: Mon Nov 18 23:27:23 2024 -0500 pom --- pom.xml | 7 --- .../dependency/PurgeLocalRepositoryMojo.java | 64 +++++++++++++--------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/pom.xml b/pom.xml index f23a6d61..a6491f10 100644 --- a/pom.xml +++ b/pom.xml @@ -188,7 +188,6 @@ under the License. <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.17.0</version> - <scope>runtime</scope> </dependency> <dependency> <groupId>commons-io</groupId> @@ -258,12 +257,6 @@ under the License. <version>3.4.2</version> </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - <version>3.13.0</version> - </dependency> - <!-- dependencies to annotations --> <dependency> <groupId>org.apache.maven.plugin-tools</groupId> 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. */