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/19 13:50:19 UTC
(maven-acr-plugin) 01/01: Prefer Guice injection
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-acr-plugin.git
commit cb137d20e131a04a58e55dfe791caf035b959870
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Thu Dec 19 08:50:08 2024 -0500
Prefer Guice injection
---
pom.xml | 6 +++++
.../java/org/apache/maven/plugins/acr/AcrMojo.java | 31 +++++++++++-----------
2 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/pom.xml b/pom.xml
index 744e7db..6d045d3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -103,6 +103,12 @@ under the License.
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
diff --git a/src/main/java/org/apache/maven/plugins/acr/AcrMojo.java b/src/main/java/org/apache/maven/plugins/acr/AcrMojo.java
index e66e500..e3fc0cf 100644
--- a/src/main/java/org/apache/maven/plugins/acr/AcrMojo.java
+++ b/src/main/java/org/apache/maven/plugins/acr/AcrMojo.java
@@ -18,6 +18,9 @@
*/
package org.apache.maven.plugins.acr;
+import javax.inject.Inject;
+import javax.inject.Named;
+
import java.io.File;
import java.io.IOException;
import java.util.List;
@@ -29,7 +32,6 @@ import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
-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;
@@ -39,7 +41,6 @@ import org.apache.maven.shared.filtering.FilterWrapper;
import org.apache.maven.shared.filtering.MavenFileFilter;
import org.apache.maven.shared.filtering.MavenFilteringException;
import org.apache.maven.shared.filtering.MavenResourcesExecution;
-import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.jar.JarArchiver;
import org.codehaus.plexus.archiver.jar.ManifestException;
@@ -107,12 +108,6 @@ public class AcrMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;
- /**
- * The Jar archiver.
- */
- @Component(role = Archiver.class, hint = "jar")
- private JarArchiver jarArchiver;
-
/**
* The archive configuration to use. See <a href="https://maven.apache.org/shared/maven-archiver/index.html">Maven
* Archiver Reference</a>.
@@ -149,13 +144,6 @@ public class AcrMojo extends AbstractMojo {
@Parameter
private List<String> filters;
- /**
- */
- @Component(role = MavenFileFilter.class, hint = "default")
- private MavenFileFilter mavenFileFilter;
-
- /**
- */
@Parameter(defaultValue = "${session}", readonly = true, required = true)
private MavenSession session;
@@ -169,6 +157,19 @@ public class AcrMojo extends AbstractMojo {
@Parameter(defaultValue = "${project.build.outputTimestamp}")
private String outputTimestamp;
+ /**
+ * The Jar archiver.
+ */
+ private final JarArchiver jarArchiver;
+
+ private final MavenFileFilter mavenFileFilter;
+
+ @Inject
+ public AcrMojo(JarArchiver jarArchiver, @Named("default") MavenFileFilter mavenFileFilter) {
+ this.jarArchiver = jarArchiver;
+ this.mavenFileFilter = mavenFileFilter;
+ }
+
/** {@inheritDoc} */
public void execute() throws MojoExecutionException {
if (getLog().isInfoEnabled()) {