@Mojo(name="exec",
threadSafe=true,
requiresDependencyResolution=TEST)
public class ExecMojo
extends AbstractExecMojo
| Modifier and Type | Field and Description |
|---|---|
private java.util.List<?> |
arguments
A list of arguments passed to the
executable, which should be of type <argument> or
<classpath>. |
private boolean |
async
If set to true the child process executes asynchronously and build execution continues in parallel.
|
private boolean |
asyncDestroyOnShutdown
If set to true, the asynchronous child process is destroyed upon JVM shutdown.
|
private java.io.File |
basedir |
static java.lang.String |
CLASSPATH_TOKEN |
private java.io.File |
environmentScript
Environment script to be merged with environmentVariables This script is platform specifics, on Unix its
must be Bourne shell format.
|
private java.util.Map<java.lang.String,java.lang.String> |
environmentVariables
Environment variables to pass to the executed program.
|
private java.lang.String |
executable
The executable.
|
private boolean |
longClasspath
If set to true the classpath and the main class will be written to a MANIFEST.MF file and wrapped into a jar.
|
private boolean |
longModulepath
If set to true the modulepath and the main class will be written as an @arg file
Instead of '--module-path/-p MODULEPATH ' the exec plugin executes '@modulepath'.
|
static java.lang.String |
MODULEPATH_TOKEN |
private java.io.File |
outputFile
Program standard and error output will be redirected to the file specified by this optional field.
|
private org.apache.commons.exec.ProcessDestroyer |
processDestroyer |
private org.apache.maven.execution.MavenSession |
session
The current build session instance.
|
private int[] |
successCodes
Exit codes to be resolved as successful execution for non-compliant applications (applications not returning 0
for success).
|
private java.lang.String |
toolchain
The toolchain.
|
private java.io.File |
workingDirectory
The current working directory.
|
classpathScope, executableDependency, project| Constructor and Description |
|---|
ExecMojo() |
| Modifier and Type | Method and Description |
|---|---|
private static void |
addToClasspath(java.lang.StringBuffer theClasspath,
java.lang.String toAdd) |
private java.lang.String |
computeClasspathString(AbstractPath specifiedClasspath)
Compute the classpath from the specified Classpath.
|
private java.util.List<java.lang.String> |
computePath(AbstractPath specifiedClasspath)
Compute the classpath from the specified Classpath.
|
private void |
createArgFile(java.lang.String filePath,
java.util.List<java.lang.String> lines) |
protected java.util.Map<java.lang.String,java.lang.String> |
createEnvs(java.io.File envScriptFile) |
protected java.io.File |
createEnvWrapperFile(java.io.File envScript) |
private java.io.File |
createJar(java.util.List<java.lang.String> classPath,
java.lang.String mainClass)
Create a jar with just a manifest containing a Main-Class entry for SurefireBooter and a Class-Path entry for all
classpath elements.
|
void |
execute()
priority in the execute method will be to use System properties arguments over the pom specification.
|
protected int |
executeCommandLine(org.apache.commons.exec.Executor exec,
org.apache.commons.exec.CommandLine commandLine,
java.util.Map<java.lang.String,java.lang.String> enviro,
java.io.FileOutputStream outputFile) |
protected int |
executeCommandLine(org.apache.commons.exec.Executor exec,
org.apache.commons.exec.CommandLine commandLine,
java.util.Map<java.lang.String,java.lang.String> enviro,
java.io.OutputStream out,
java.io.OutputStream err) |
protected int |
executeCommandLine(org.apache.commons.exec.Executor exec,
org.apache.commons.exec.CommandLine commandLine,
java.util.Map<java.lang.String,java.lang.String> enviro,
org.apache.commons.exec.PumpStreamHandler psh) |
private void |
fillSuccessCodes(org.apache.commons.exec.Executor exec) |
private java.util.List<org.apache.maven.artifact.Artifact> |
filterArtifacts(java.util.List<org.apache.maven.artifact.Artifact> artifacts,
java.util.Collection<java.lang.String> dependencies) |
(package private) static java.lang.String |
findExecutable(java.lang.String executable,
java.util.List<java.lang.String> paths) |
(package private) java.lang.String |
getExecutable() |
private static java.util.List<java.lang.String> |
getExecutableExtensions() |
(package private) org.apache.commons.exec.CommandLine |
getExecutablePath(java.util.Map<java.lang.String,java.lang.String> enviro,
java.io.File dir) |
private java.util.List<java.lang.String> |
getExecutablePaths(java.util.Map<java.lang.String,java.lang.String> enviro) |
protected org.apache.commons.exec.ProcessDestroyer |
getProcessDestroyer() |
int[] |
getSuccessCodes() |
protected java.lang.String |
getSystemProperty(java.lang.String key) |
private org.apache.maven.toolchain.Toolchain |
getToolchain() |
private void |
handleArguments(java.util.List<java.lang.String> commandArguments) |
private void |
handleCommandLineArgs(java.util.List<java.lang.String> commandArguments) |
private java.util.Map<java.lang.String,java.lang.String> |
handleSystemEnvVariables() |
private void |
handleSystemPropertyArguments(java.lang.String argsProp,
java.util.List<java.lang.String> commandArguments) |
private void |
handleWorkingDirectory()
This is a convenient method to make the execute method a little bit more readable.
|
private static boolean |
hasExecutableExtension(java.lang.String exec) |
private static boolean |
hasNativeExtension(java.lang.String exec) |
private boolean |
isLongClassPathArgument(java.lang.String arg) |
private boolean |
isLongModulePathArgument(java.lang.String arg) |
(package private) boolean |
isResultCodeAFailure(int result) |
(package private) void |
setArguments(java.util.List<?> arguments) |
(package private) void |
setBasedir(java.io.File basedir) |
(package private) void |
setExecutable(java.lang.String executable) |
(package private) void |
setProject(org.apache.maven.project.MavenProject project) |
void |
setSuccessCodes(java.lang.Integer... list) |
(package private) void |
setWorkingDirectory(java.io.File workingDir) |
(package private) void |
setWorkingDirectory(java.lang.String workingDir) |
collectProjectArtifactsAndClasspath, findExecutableArtifact, hasCommandlineArgs, isSkip, parseCommandlineArgs, registerSourceRoots@Parameter(property="exec.executable") private java.lang.String executable
The executable. Can be a full path or the name of the executable. In the latter case, the executable must be in
the PATH for the execution to work. Omit when using executableDependency.
The plugin will search for the executable in the following order:
@Parameter(property="exec.toolchain",
defaultValue="jdk")
private java.lang.String toolchain
The toolchain. If omitted, "jdk" is assumed.
@Parameter(property="exec.workingdir") private java.io.File workingDirectory
@Parameter(property="exec.outputFile") private java.io.File outputFile
System.out and System.err use buffering, so don't
rely on the order!System.err,
System.in@Parameter private java.util.List<?> arguments
A list of arguments passed to the executable, which should be of type <argument> or
<classpath>. Can be overridden by using the exec.args environment variable.
@Parameter(readonly=true,
required=true,
defaultValue="${basedir}")
private java.io.File basedir
@Parameter private java.util.Map<java.lang.String,java.lang.String> environmentVariables
@Parameter private java.io.File environmentScript
@Parameter(defaultValue="${session}",
readonly=true)
private org.apache.maven.execution.MavenSession session
@Parameter private int[] successCodes
@Parameter(property="exec.longClasspath",
defaultValue="false")
private boolean longClasspath
@Parameter(property="exec.longModulepath",
defaultValue="true")
private boolean longModulepath
@Parameter(property="exec.async",
defaultValue="false")
private boolean async
@Parameter(property="exec.asyncDestroyOnShutdown",
defaultValue="true")
private boolean asyncDestroyOnShutdown
public static final java.lang.String CLASSPATH_TOKEN
public static final java.lang.String MODULEPATH_TOKEN
private org.apache.commons.exec.ProcessDestroyer processDestroyer
public void execute()
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException - if a failure happensprivate java.util.Map<java.lang.String,java.lang.String> handleSystemEnvVariables()
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate void handleWorkingDirectory()
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate void handleSystemPropertyArguments(java.lang.String argsProp,
java.util.List<java.lang.String> commandArguments)
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate void handleCommandLineArgs(java.util.List<java.lang.String> commandArguments)
throws org.apache.maven.plugin.MojoExecutionException,
java.io.IOException
org.apache.maven.plugin.MojoExecutionExceptionjava.io.IOExceptionprivate void handleArguments(java.util.List<java.lang.String> commandArguments)
throws org.apache.maven.plugin.MojoExecutionException,
java.io.IOException
org.apache.maven.plugin.MojoExecutionExceptionjava.io.IOExceptionprivate void fillSuccessCodes(org.apache.commons.exec.Executor exec)
boolean isResultCodeAFailure(int result)
private boolean isLongClassPathArgument(java.lang.String arg)
private boolean isLongModulePathArgument(java.lang.String arg)
private java.lang.String computeClasspathString(AbstractPath specifiedClasspath)
specifiedClasspath - Non null when the user restricted the dependencies, null otherwise (the
default classpath will be used)private java.util.List<java.lang.String> computePath(AbstractPath specifiedClasspath)
specifiedClasspath - Non null when the user restricted the dependencies, null otherwise (the
default classpath will be used)private static void addToClasspath(java.lang.StringBuffer theClasspath,
java.lang.String toAdd)
private java.util.List<org.apache.maven.artifact.Artifact> filterArtifacts(java.util.List<org.apache.maven.artifact.Artifact> artifacts,
java.util.Collection<java.lang.String> dependencies)
org.apache.commons.exec.CommandLine getExecutablePath(java.util.Map<java.lang.String,java.lang.String> enviro,
java.io.File dir)
static java.lang.String findExecutable(java.lang.String executable,
java.util.List<java.lang.String> paths)
private static boolean hasNativeExtension(java.lang.String exec)
private static boolean hasExecutableExtension(java.lang.String exec)
private static java.util.List<java.lang.String> getExecutableExtensions()
private java.util.List<java.lang.String> getExecutablePaths(java.util.Map<java.lang.String,java.lang.String> enviro)
protected int executeCommandLine(org.apache.commons.exec.Executor exec,
org.apache.commons.exec.CommandLine commandLine,
java.util.Map<java.lang.String,java.lang.String> enviro,
java.io.OutputStream out,
java.io.OutputStream err)
throws org.apache.commons.exec.ExecuteException,
java.io.IOException
org.apache.commons.exec.ExecuteExceptionjava.io.IOExceptionprotected int executeCommandLine(org.apache.commons.exec.Executor exec,
org.apache.commons.exec.CommandLine commandLine,
java.util.Map<java.lang.String,java.lang.String> enviro,
java.io.FileOutputStream outputFile)
throws org.apache.commons.exec.ExecuteException,
java.io.IOException
org.apache.commons.exec.ExecuteExceptionjava.io.IOExceptionprotected int executeCommandLine(org.apache.commons.exec.Executor exec,
org.apache.commons.exec.CommandLine commandLine,
java.util.Map<java.lang.String,java.lang.String> enviro,
org.apache.commons.exec.PumpStreamHandler psh)
throws org.apache.commons.exec.ExecuteException,
java.io.IOException
org.apache.commons.exec.ExecuteExceptionjava.io.IOExceptionvoid setExecutable(java.lang.String executable)
java.lang.String getExecutable()
void setWorkingDirectory(java.lang.String workingDir)
void setWorkingDirectory(java.io.File workingDir)
void setArguments(java.util.List<?> arguments)
void setBasedir(java.io.File basedir)
void setProject(org.apache.maven.project.MavenProject project)
protected java.lang.String getSystemProperty(java.lang.String key)
public void setSuccessCodes(java.lang.Integer... list)
public int[] getSuccessCodes()
private org.apache.maven.toolchain.Toolchain getToolchain()
private java.io.File createJar(java.util.List<java.lang.String> classPath,
java.lang.String mainClass)
throws java.io.IOException
classPath - List<String> of all classpath elements.java.io.IOExceptionprivate void createArgFile(java.lang.String filePath,
java.util.List<java.lang.String> lines)
throws java.io.IOException
java.io.IOExceptionprotected java.util.Map<java.lang.String,java.lang.String> createEnvs(java.io.File envScriptFile)
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprotected java.io.File createEnvWrapperFile(java.io.File envScript)
throws java.io.IOException
java.io.IOExceptionprotected org.apache.commons.exec.ProcessDestroyer getProcessDestroyer()