Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rfscholte committed Dec 18, 2024
1 parent 0824d43 commit 52d6737
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@
*/
package io.micronaut.maven.aot;

import io.micronaut.maven.MojoUtils;
import io.micronaut.maven.services.CompilerService;
import io.micronaut.maven.services.DependencyResolutionService;
import io.micronaut.maven.services.ExecutorService;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.invoker.InvocationResult;
import org.apache.maven.shared.invoker.MavenInvocationException;
import org.apache.maven.toolchain.ToolchainManager;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.eclipse.aether.artifact.Artifact;
Expand Down Expand Up @@ -74,6 +78,10 @@ public abstract class AbstractMicronautAotCliMojo extends AbstractMicronautAotMo
private final ExecutorService executorService;

private final DependencyResolutionService dependencyResolutionService;

private final MavenSession mavenSession;

private final ToolchainManager toolchainManager;

@Parameter
private List<org.apache.maven.model.Dependency> aotDependencies;
Expand All @@ -88,10 +96,13 @@ public abstract class AbstractMicronautAotCliMojo extends AbstractMicronautAotMo

@Inject
public AbstractMicronautAotCliMojo(CompilerService compilerService, ExecutorService executorService,
MavenProject mavenProject, DependencyResolutionService dependencyResolutionService) {
MavenProject mavenProject, DependencyResolutionService dependencyResolutionService,
MavenSession mavenSession, ToolchainManager toolchainManager) {
super(compilerService, mavenProject);
this.executorService = executorService;
this.dependencyResolutionService = dependencyResolutionService;
this.mavenSession = mavenSession;
this.toolchainManager = toolchainManager;
}

protected abstract List<String> getExtraArgs() throws MojoExecutionException;
Expand Down Expand Up @@ -161,8 +172,11 @@ private Xpp3Dom createExecPluginConfig() throws DependencyResolutionException, M
MojoExecutor.Element[] runnerArgs = Stream.concat(Stream.concat(jvmArgs, mainArgs), getExtraArgs().stream())
.map(arg -> element("argument", arg))
.toArray(MojoExecutor.Element[]::new);

String javaExecutable = MojoUtils.findJavaExecutable(toolchainManager, mavenSession);

return configuration(
element("executable", "java"),
element("executable", javaExecutable),
element("arguments", runnerArgs)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
import io.micronaut.maven.services.DependencyResolutionService;
import io.micronaut.maven.services.ExecutorService;
import org.apache.commons.io.FileUtils;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.apache.maven.toolchain.ToolchainManager;

import javax.inject.Inject;
import java.io.File;
Expand Down Expand Up @@ -73,8 +75,9 @@ public class AotAnalysisMojo extends AbstractMicronautAotCliMojo {
@Inject
@SuppressWarnings("CdiInjectionPointsInspection")
public AotAnalysisMojo(CompilerService compilerService, ExecutorService executorService, MavenProject mavenProject,
DependencyResolutionService dependencyResolutionService) {
super(compilerService, executorService, mavenProject, dependencyResolutionService);
DependencyResolutionService dependencyResolutionService,
MavenSession mavenSession, ToolchainManager toolchainManager) {
super(compilerService, executorService, mavenProject, dependencyResolutionService, mavenSession, toolchainManager);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
import io.micronaut.maven.services.CompilerService;
import io.micronaut.maven.services.DependencyResolutionService;
import io.micronaut.maven.services.ExecutorService;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.apache.maven.toolchain.ToolchainManager;

import javax.inject.Inject;
import java.io.File;
Expand All @@ -39,8 +42,9 @@ public class AotSampleMojo extends AbstractMicronautAotCliMojo {

@Inject
public AotSampleMojo(CompilerService compilerService, ExecutorService executorService, MavenProject mavenProject,
DependencyResolutionService dependencyResolutionService) {
super(compilerService, executorService, mavenProject, dependencyResolutionService);
DependencyResolutionService dependencyResolutionService,
MavenSession mavenSession, ToolchainManager toolchainManager) {
super(compilerService, executorService, mavenProject, dependencyResolutionService, mavenSession, toolchainManager);
}

@Override
Expand Down

0 comments on commit 52d6737

Please sign in to comment.