From 65d700fa790b85cbf830ddcbaa76ae883ad1c9fe Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Thu, 19 Dec 2024 18:16:24 -0500 Subject: [PATCH] Prefer Guice injection --- .../org/apache/maven/plugins/ejb/EjbMojo.java | 58 ++++++++++--------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java b/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java index 99dbd90..38bf0a9 100644 --- a/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java +++ b/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.ejb; +import javax.inject.Inject; + import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -31,7 +33,6 @@ 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; @@ -42,7 +43,6 @@ 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; @@ -62,6 +62,10 @@ public class EjbMojo extends AbstractMojo { private static final List DEFAULT_INCLUDES_LIST = Collections.unmodifiableList(Arrays.asList("**/**")); + private static final String EJB_TYPE = "ejb"; + + private static final String EJB_CLIENT_TYPE = "ejb-client"; + // @formatter:off private static final List DEFAULT_CLIENT_EXCLUDES_LIST = Collections.unmodifiableList( Arrays.asList("**/*Bean.class", "**/*CMP.class", "**/*Session.class", "**/package.html")); @@ -179,12 +183,6 @@ public class EjbMojo extends AbstractMojo { @Parameter(defaultValue = "${project}", readonly = true, required = true) private MavenProject project; - /** - * The Jar archiver. - */ - @Component(role = Archiver.class, hint = "jar") - private JarArchiver jarArchiver; - /** * What EJB version should the EJB Plugin generate? Valid values are "2.x", "3.x" or "4.x" (where x is a digit). * When ejbVersion is "2.x", the ejb-jar.xml file is mandatory. @@ -200,18 +198,6 @@ public class EjbMojo extends AbstractMojo { @Parameter(defaultValue = "3.1") private String ejbVersion; - /** - * The client Jar archiver. - */ - @Component(role = Archiver.class, hint = "jar") - private JarArchiver clientJarArchiver; - - /** - * The Maven project's helper. - */ - @Component - private MavenProjectHelper projectHelper; - /** * The archive configuration to use. See Maven * Archiver Reference. @@ -251,12 +237,6 @@ public class EjbMojo extends AbstractMojo { @Parameter private List filters; - /** - * @since 2.3 - */ - @Component(role = MavenFileFilter.class, hint = "default") - private MavenFileFilter mavenFileFilter; - /** * @since 2.3 */ @@ -273,9 +253,31 @@ public class EjbMojo extends AbstractMojo { @Parameter(defaultValue = "${project.build.outputTimestamp}") private String outputTimestamp; - private static final String EJB_TYPE = "ejb"; + /** + * The Jar archiver. + */ + private final JarArchiver jarArchiver = new JarArchiver(); - private static final String EJB_CLIENT_TYPE = "ejb-client"; + /** + * The client Jar archiver. + */ + private JarArchiver clientJarArchiver = new JarArchiver(); + + /** + * The Maven project's helper. + */ + private final MavenProjectHelper projectHelper; + + /** + * @since 2.3 + */ + private final MavenFileFilter mavenFileFilter; + + @Inject + public EjbMojo(MavenProjectHelper projectHelper, MavenFileFilter mavenFileFilter) { + this.projectHelper = projectHelper; + this.mavenFileFilter = mavenFileFilter; + } /** * Generates an EJB jar and optionally an ejb-client jar.