|
|
|
@ -30,15 +30,20 @@ import java.util.Set;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import org.apache.maven.artifact.Artifact;
|
|
|
|
|
import org.apache.maven.execution.MavenSession;
|
|
|
|
|
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.Parameter;
|
|
|
|
|
import org.apache.maven.project.MavenProject;
|
|
|
|
|
import org.apache.maven.shared.artifact.filter.collection.AbstractArtifactFeatureFilter;
|
|
|
|
|
import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
|
|
|
|
|
import org.apache.maven.toolchain.Toolchain;
|
|
|
|
|
import org.apache.maven.toolchain.ToolchainManager;
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.loader.tools.FileUtils;
|
|
|
|
|
import org.springframework.boot.loader.tools.JavaExecutable;
|
|
|
|
|
import org.springframework.boot.loader.tools.MainClassFinder;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -64,6 +69,20 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
|
|
|
|
@Parameter(defaultValue = "${project}", readonly = true, required = true)
|
|
|
|
|
private MavenProject project;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The current Maven session. This is used for toolchain manager API calls.
|
|
|
|
|
* @since 2.3.0
|
|
|
|
|
*/
|
|
|
|
|
@Parameter(defaultValue = "${session}", readonly = true)
|
|
|
|
|
private MavenSession session;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The toolchain manager to use to locate a custom JDK.
|
|
|
|
|
* @since 2.3.0
|
|
|
|
|
*/
|
|
|
|
|
@Component
|
|
|
|
|
private ToolchainManager toolchainManager;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add maven resources to the classpath directly, this allows live in-place editing of
|
|
|
|
|
* resources. Duplicate resources are removed from {@code target/classes} to prevent
|
|
|
|
@ -325,6 +344,16 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
|
|
|
|
return runArguments;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Provides access to the java binary executable, regardless of OS.
|
|
|
|
|
* @return the java executable
|
|
|
|
|
**/
|
|
|
|
|
protected String getJavaExecutable() {
|
|
|
|
|
Toolchain toolchain = this.toolchainManager.getToolchainFromBuildContext("jdk", this.session);
|
|
|
|
|
String javaExecutable = (toolchain != null) ? toolchain.findTool("java") : null;
|
|
|
|
|
return (javaExecutable != null) ? javaExecutable : new JavaExecutable().toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Resolve the environment variables to use.
|
|
|
|
|
* @return an {@link EnvVariables} defining the environment variables
|
|
|
|
|