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-gpg-plugin.git
The following commit(s) were added to refs/heads/master by this push: new 805077c Prefer Guice constructor injection (#126) 805077c is described below commit 805077c80f457d432637ddef647829a038d63142 Author: Elliotte Rusty Harold <elh...@users.noreply.github.com> AuthorDate: Wed Dec 18 22:41:02 2024 +0000 Prefer Guice constructor injection (#126) --- .../maven/plugins/gpg/GpgSignAttachedMojo.java | 15 +++++++---- .../maven/plugins/gpg/SignAndDeployFileMojo.java | 29 ++++++++++++++-------- .../apache/maven/plugins/gpg/SignDeployedMojo.java | 11 +++++--- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/gpg/GpgSignAttachedMojo.java b/src/main/java/org/apache/maven/plugins/gpg/GpgSignAttachedMojo.java index 9eb9a90..7555de1 100644 --- a/src/main/java/org/apache/maven/plugins/gpg/GpgSignAttachedMojo.java +++ b/src/main/java/org/apache/maven/plugins/gpg/GpgSignAttachedMojo.java @@ -18,12 +18,13 @@ */ package org.apache.maven.plugins.gpg; +import javax.inject.Inject; + import java.io.File; import java.util.List; 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.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -60,14 +61,18 @@ public class GpgSignAttachedMojo extends AbstractGpgMojo { /** * The maven project. */ - @Component - protected MavenProject project; + protected final MavenProject project; /** * Maven ProjectHelper */ - @Component - private MavenProjectHelper projectHelper; + private final MavenProjectHelper projectHelper; + + @Inject + public GpgSignAttachedMojo(MavenProject project, MavenProjectHelper projectHelper) { + this.project = project; + this.projectHelper = projectHelper; + } @Override protected void doExecute() throws MojoExecutionException, MojoFailureException { diff --git a/src/main/java/org/apache/maven/plugins/gpg/SignAndDeployFileMojo.java b/src/main/java/org/apache/maven/plugins/gpg/SignAndDeployFileMojo.java index db4e09c..cbe0205 100644 --- a/src/main/java/org/apache/maven/plugins/gpg/SignAndDeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/gpg/SignAndDeployFileMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.gpg; +import javax.inject.Inject; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -41,7 +43,6 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.model.validation.ModelValidator; 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; @@ -185,30 +186,36 @@ public class SignAndDeployFileMojo extends AbstractGpgMojo { @Parameter(property = "files") private String files; - /** - */ - @Component - private RepositorySystem repositorySystem; + private final RepositorySystem repositorySystem; /** * The component used to validate the user-supplied artifact coordinates. */ - @Component - private ModelValidator modelValidator; + private final ModelValidator modelValidator; /** * The default Maven project created when building the plugin * * @since 1.3 */ - @Component - private MavenProject project; + private final MavenProject project; /** * @since 3.2.0 */ - @Component - private ArtifactHandlerManager artifactHandlerManager; + private final ArtifactHandlerManager artifactHandlerManager; + + @Inject + public SignAndDeployFileMojo( + RepositorySystem repositorySystem, + ModelValidator modelValidator, + MavenProject project, + ArtifactHandlerManager artifactHandlerManager) { + this.repositorySystem = repositorySystem; + this.modelValidator = modelValidator; + this.project = project; + this.artifactHandlerManager = artifactHandlerManager; + } private void initProperties() throws MojoExecutionException { // Process the supplied POM (if there is one) diff --git a/src/main/java/org/apache/maven/plugins/gpg/SignDeployedMojo.java b/src/main/java/org/apache/maven/plugins/gpg/SignDeployedMojo.java index a05c230..5f8e22c 100644 --- a/src/main/java/org/apache/maven/plugins/gpg/SignDeployedMojo.java +++ b/src/main/java/org/apache/maven/plugins/gpg/SignDeployedMojo.java @@ -38,7 +38,6 @@ import java.util.stream.Stream; 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.codehaus.plexus.util.FileUtils; @@ -106,11 +105,15 @@ public class SignDeployedMojo extends AbstractGpgMojo { @Parameter(property = "artifacts") private String artifacts; - @Component - private RepositorySystem repositorySystem; + private final RepositorySystem repositorySystem; + + private final Map<String, ArtifactCollectorSPI> artifactCollectors; @Inject - private Map<String, ArtifactCollectorSPI> artifactCollectors; + public SignDeployedMojo(RepositorySystem repositorySystem, Map<String, ArtifactCollectorSPI> artifactCollectors) { + this.repositorySystem = repositorySystem; + this.artifactCollectors = artifactCollectors; + } @Override protected void doExecute() throws MojoExecutionException, MojoFailureException {