Package org.apache.maven.shared.invoker
Class DefaultInvoker
- java.lang.Object
-
- org.apache.maven.shared.invoker.DefaultInvoker
-
-
Field Summary
Fields Modifier and Type Field Description private static InvokerLogger
DEFAULT_LOGGER
private static InvocationOutputHandler
DEFAULT_OUTPUT_HANDLER
private InvocationOutputHandler
errorHandler
private java.io.InputStream
inputStream
private java.io.File
localRepositoryDirectory
private InvokerLogger
logger
private java.io.File
mavenExecutable
private java.io.File
mavenHome
private InvocationOutputHandler
outputHandler
static java.lang.String
ROLE_HINT
ConstantROLE_HINT="default"
private java.io.File
workingDirectory
-
Constructor Summary
Constructors Constructor Description DefaultInvoker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InvocationResult
execute(InvocationRequest request)
Executes Maven using the parameters specified by the given invocation request.private int
executeCommandLine(org.apache.maven.shared.utils.cli.Commandline cli, InvocationRequest request, int timeoutInSeconds)
java.io.File
getLocalRepositoryDirectory()
Getter for the fieldlocalRepositoryDirectory
.InvokerLogger
getLogger()
Getter for the fieldlogger
.java.io.File
getMavenExecutable()
Getter for the fieldmavenExecutable
.java.io.File
getMavenHome()
Getter for the fieldmavenHome
.java.io.File
getWorkingDirectory()
Getter for the fieldworkingDirectory
.Invoker
setErrorHandler(InvocationOutputHandler errorHandler)
Sets the handler used to capture the error output from the Maven build.Invoker
setInputStream(java.io.InputStream inputStream)
Sets the input stream used to provide input for the invoked Maven build.Invoker
setLocalRepositoryDirectory(java.io.File localRepositoryDirectory)
Sets the path to the base directory of the local repository to use for the Maven invocation.Invoker
setLogger(InvokerLogger logger)
Sets the logger used by this invoker to output diagnostic messages.Invoker
setMavenExecutable(java.io.File mavenExecutable)
mavenExecutable
can either be a file relative to ${maven.home}/bin/ or an absolute file.Invoker
setMavenHome(java.io.File mavenHome)
Sets the path to the base directory of the Maven installation used to invoke Maven.Invoker
setOutputHandler(InvocationOutputHandler outputHandler)
Sets the handler used to capture the standard output from the Maven build.Invoker
setWorkingDirectory(java.io.File workingDirectory)
Sets the working directory for the Maven invocation.
-
-
-
Field Detail
-
ROLE_HINT
public static final java.lang.String ROLE_HINT
ConstantROLE_HINT="default"
- See Also:
- Constant Field Values
-
DEFAULT_LOGGER
private static final InvokerLogger DEFAULT_LOGGER
-
DEFAULT_OUTPUT_HANDLER
private static final InvocationOutputHandler DEFAULT_OUTPUT_HANDLER
-
localRepositoryDirectory
private java.io.File localRepositoryDirectory
-
logger
private InvokerLogger logger
-
workingDirectory
private java.io.File workingDirectory
-
mavenHome
private java.io.File mavenHome
-
mavenExecutable
private java.io.File mavenExecutable
-
outputHandler
private InvocationOutputHandler outputHandler
-
inputStream
private java.io.InputStream inputStream
-
errorHandler
private InvocationOutputHandler errorHandler
-
-
Method Detail
-
execute
public InvocationResult execute(InvocationRequest request) throws MavenInvocationException
Executes Maven using the parameters specified by the given invocation request. Parameters not specified by the invocation request will be derived from the state of this invoker instance. In case both the invoker instance and the invocation request provide a value for a particular option, the value from the invocation request dominates.- Specified by:
execute
in interfaceInvoker
- Parameters:
request
- The invocation request to execute, must not benull
.- Returns:
- The result of the Maven invocation, never
null
. - Throws:
MavenInvocationException
- if cannot configure correctly execution parameters
-
executeCommandLine
private int executeCommandLine(org.apache.maven.shared.utils.cli.Commandline cli, InvocationRequest request, int timeoutInSeconds) throws org.apache.maven.shared.utils.cli.CommandLineException
- Throws:
org.apache.maven.shared.utils.cli.CommandLineException
-
getLocalRepositoryDirectory
public java.io.File getLocalRepositoryDirectory()
Getter for the field
localRepositoryDirectory
.- Specified by:
getLocalRepositoryDirectory
in interfaceInvoker
- Returns:
- a
File
object.
-
getLogger
public InvokerLogger getLogger()
Getter for the field
logger
.- Specified by:
getLogger
in interfaceInvoker
- Returns:
- a
InvokerLogger
object.
-
setLocalRepositoryDirectory
public Invoker setLocalRepositoryDirectory(java.io.File localRepositoryDirectory)
Sets the path to the base directory of the local repository to use for the Maven invocation.- Specified by:
setLocalRepositoryDirectory
in interfaceInvoker
- Parameters:
localRepositoryDirectory
- The path to the base directory of the local repository ornull
to use the location from thesettings.xml
.- Returns:
- This invoker instance.
-
setLogger
public Invoker setLogger(InvokerLogger logger)
Sets the logger used by this invoker to output diagnostic messages.
-
getWorkingDirectory
public java.io.File getWorkingDirectory()
Getter for the field
workingDirectory
.- Specified by:
getWorkingDirectory
in interfaceInvoker
- Returns:
- a
File
object.
-
setWorkingDirectory
public Invoker setWorkingDirectory(java.io.File workingDirectory)
Sets the working directory for the Maven invocation.- Specified by:
setWorkingDirectory
in interfaceInvoker
- Parameters:
workingDirectory
- The working directory for the Maven invocation, may benull
to derive the working directory from the base directory of the processed POM.- Returns:
- This invoker instance.
-
getMavenHome
public java.io.File getMavenHome()
Getter for the field
mavenHome
.- Specified by:
getMavenHome
in interfaceInvoker
- Returns:
- a
File
object.
-
setMavenHome
public Invoker setMavenHome(java.io.File mavenHome)
Sets the path to the base directory of the Maven installation used to invoke Maven. This parameter may be left unspecified to use the default Maven installation which will be discovered by evaluating the system propertymaven.home
and the environment variableM2_HOME
.- Specified by:
setMavenHome
in interfaceInvoker
- Parameters:
mavenHome
- The path to the base directory of the Maven installation, may benull
to use the default Maven installation.- Returns:
- This invoker instance.
-
getMavenExecutable
public java.io.File getMavenExecutable()
Getter for the field
mavenExecutable
.- Specified by:
getMavenExecutable
in interfaceInvoker
- Returns:
- a
File
object.
-
setMavenExecutable
public Invoker setMavenExecutable(java.io.File mavenExecutable)
mavenExecutable
can either be a file relative to ${maven.home}/bin/ or an absolute file.- Specified by:
setMavenExecutable
in interfaceInvoker
- Parameters:
mavenExecutable
- the executable- Returns:
- This invoker instance
-
setErrorHandler
public Invoker setErrorHandler(InvocationOutputHandler errorHandler)
Sets the handler used to capture the error output from the Maven build.- Specified by:
setErrorHandler
in interfaceInvoker
- Parameters:
errorHandler
- The error handler, may benull
if the output is not of interest.- Returns:
- This invoker instance.
-
setInputStream
public Invoker setInputStream(java.io.InputStream inputStream)
Sets the input stream used to provide input for the invoked Maven build. This is in particular useful when invoking Maven in interactive mode.- Specified by:
setInputStream
in interfaceInvoker
- Parameters:
inputStream
- The input stream used to provide input for the invoked Maven build, may benull
if not required.- Returns:
- This invoker instance.
-
setOutputHandler
public Invoker setOutputHandler(InvocationOutputHandler outputHandler)
Sets the handler used to capture the standard output from the Maven build.- Specified by:
setOutputHandler
in interfaceInvoker
- Parameters:
outputHandler
- The output handler, may benull
if the output is not of interest.- Returns:
- This invoker instance.
-
-