Skip to content

Commit

Permalink
Use Guice injection for ZipArchiver (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo authored Dec 19, 2024
1 parent ccc252b commit 1a5742b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*/

import javax.inject.Inject;
import javax.inject.Named;

import java.io.File;
import java.io.IOException;
Expand All @@ -59,7 +60,6 @@
import org.apache.maven.model.Resource;
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;
Expand All @@ -73,7 +73,6 @@
import org.apache.maven.toolchain.ToolchainManager;
import org.apache.maven.toolchain.ToolchainPrivate;
import org.apache.maven.toolchain.java.DefaultJavaToolChain;
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.zip.ZipArchiver;
import org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor;
Expand Down Expand Up @@ -330,12 +329,6 @@ public class JLinkMojo extends AbstractJLinkMojo {
@Parameter(defaultValue = "false")
private boolean verbose;

/**
* The JAR archiver needed for archiving the environments.
*/
@Component(role = Archiver.class, hint = "zip")
private ZipArchiver zipArchiver;

/**
* Set the JDK location to create a Java custom runtime image.
*/
Expand Down Expand Up @@ -385,13 +378,20 @@ public class JLinkMojo extends AbstractJLinkMojo {

private final LocationManager locationManager;

/**
* The JAR archiver needed for archiving the environments.
*/
private final ZipArchiver zipArchiver;

@Inject
public JLinkMojo(
MavenProjectHelper projectHelper,
ToolchainManager toolchainManager,
@Named("zip") ZipArchiver zipArchiver,
MavenResourcesFiltering mavenResourcesFiltering,
LocationManager locationManager) {
super(toolchainManager);
this.zipArchiver = zipArchiver;
this.mavenResourcesFiltering = mavenResourcesFiltering;
this.projectHelper = projectHelper;
this.locationManager = locationManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

public class JLinkMojoTest {

private JLinkMojo mojo = new JLinkMojo(null, null, null, null);
private JLinkMojo mojo = new JLinkMojo(null, null, null, null, null);

@BeforeEach
public void setUp() throws NoSuchFieldException, IllegalAccessException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

public class MultipleLauncherTest {

private JLinkMojo mojo = new JLinkMojo(null, null, null, null);
private JLinkMojo mojo = new JLinkMojo(null, null, null, null, null);

@Test
void testSingleLauncher() throws Exception {
Expand Down

0 comments on commit 1a5742b

Please sign in to comment.