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-scm-publish-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new ffb980a  Use Guice constructor injection (#48)
ffb980a is described below

commit ffb980ad87622aa5d3dfb193c2348d78a9cf8f23
Author: Elliotte Rusty Harold <elh...@users.noreply.github.com>
AuthorDate: Wed Dec 11 11:41:43 2024 +0000

    Use Guice constructor injection (#48)
    
    * Guicify with @Inject
---
 pom.xml                                            |  6 +++++
 .../plugins/scmpublish/AbstractScmPublishMojo.java | 28 ++++++++++++----------
 .../scmpublish/ScmPublishPublishScmMojo.java       | 11 ++++++++-
 3 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/pom.xml b/pom.xml
index 9b3d7ae..0631734 100644
--- a/pom.xml
+++ b/pom.xml
@@ -140,6 +140,12 @@ under the License.
       <artifactId>maven-scm-api</artifactId>
       <version>${scmVersion}</version>
     </dependency>
+    <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+      <version>1</version>
+      <scope>provided</scope>
+    </dependency>
     <dependency>
       <groupId>org.apache.maven.scm</groupId>
       <artifactId>maven-scm-providers-standard</artifactId>
diff --git 
a/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java 
b/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
index f750315..b8eacef 100644
--- 
a/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
+++ 
b/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
@@ -36,7 +36,6 @@ import org.apache.commons.lang3.time.DurationFormatUtils;
 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.scm.CommandParameter;
 import org.apache.maven.scm.CommandParameters;
@@ -152,18 +151,6 @@ public abstract class AbstractScmPublishMojo extends 
AbstractMojo {
     @Parameter
     private Map<String, String> providerImplementations;
 
-    /**
-     * The SCM manager.
-     */
-    @Component
-    private ScmManager scmManager;
-
-    /**
-     * Tool that gets a configured SCM repository from release configuration.
-     */
-    @Component
-    protected ScmRepositoryConfigurator scmRepositoryConfigurator;
-
     /**
      * The server id specified in the {@code settings.xml}, which should be 
used for the authentication.
      * @see <a href="https://maven.apache.org/settings.html#servers";>Settings 
Reference</a>
@@ -274,6 +261,21 @@ public abstract class AbstractScmPublishMojo extends 
AbstractMojo {
 
     protected ScmRepository scmRepository;
 
+    /**
+     * The SCM manager.
+     */
+    private final ScmManager scmManager;
+
+    /**
+     * Tool that gets a configured SCM repository from release configuration.
+     */
+    protected final ScmRepositoryConfigurator scmRepositoryConfigurator;
+
+    protected AbstractScmPublishMojo(ScmManager scmManager, 
ScmRepositoryConfigurator scmRepositoryConfigurator) {
+        this.scmManager = scmManager;
+        this.scmRepositoryConfigurator = scmRepositoryConfigurator;
+    }
+
     protected void logInfo(String format, Object... params) {
         getLog().info(String.format(format, params));
     }
diff --git 
a/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java
 
b/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java
index ed16881..2413720 100644
--- 
a/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java
+++ 
b/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java
@@ -18,6 +18,8 @@
  */
 package org.apache.maven.plugins.scmpublish;
 
+import javax.inject.Inject;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
@@ -44,6 +46,8 @@ import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.scm.manager.ScmManager;
+import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
 import org.apache.maven.shared.utils.logging.MessageUtils;
 import org.codehaus.plexus.util.MatchPatterns;
 
@@ -75,8 +79,13 @@ public class ScmPublishPublishScmMojo extends 
AbstractScmPublishMojo {
     private int files = 0;
     private long size = 0;
 
+    @Inject
+    public ScmPublishPublishScmMojo(ScmManager scmManager, 
ScmRepositoryConfigurator scmRepositoryConfigurator) {
+        super(scmManager, scmRepositoryConfigurator);
+    }
+
     /**
-     * Update scm checkout directory with content.
+     * Update SCM checkout directory with content.
      *
      * @param checkout        the scm checkout directory
      * @param dir             the content to put in scm (can be 
<code>null</code>)

Reply via email to