Package org.apache.maven.shared.invoker
Class DefaultInvoker
- java.lang.Object
-
- org.apache.maven.shared.invoker.DefaultInvoker
-
- All Implemented Interfaces:
Invoker
@Component(role=Invoker.class, hint="default") public class DefaultInvoker extends java.lang.Object implements Invoker
Class intended to be used by clients who wish to invoke a forked Maven process from their applications- Author:
- jdcasey
-
-
Constructor Summary
Constructors Constructor Description DefaultInvoker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InvocationResultexecute(InvocationRequest request)Executes Maven using the parameters specified by the given invocation request.java.io.FilegetLocalRepositoryDirectory()Gets the path to the base directory of the local repository to use for the Maven invocation.InvokerLoggergetLogger()Gets the logger used by this invoker to output diagnostic messages.java.io.FilegetMavenExecutable()Get the customized File of the Maven executable.java.io.FilegetMavenHome()Gets the path to the base directory of the Maven installation used to invoke Maven.java.io.FilegetWorkingDirectory()Gets the working directory for the Maven invocation.InvokersetErrorHandler(InvocationOutputHandler errorHandler)Sets the handler used to capture the error output from the Maven build.InvokersetInputStream(java.io.InputStream inputStream)Sets the input stream used to provide input for the invoked Maven build.InvokersetLocalRepositoryDirectory(java.io.File localRepositoryDirectory)Sets the path to the base directory of the local repository to use for the Maven invocation.InvokersetLogger(InvokerLogger logger)Sets the logger used by this invoker to output diagnostic messages.InvokersetMavenExecutable(java.io.File mavenExecutable)mavenExecutablecan either be a file relative to ${maven.home}/bin/ or an absolute file.InvokersetMavenHome(java.io.File mavenHome)Sets the path to the base directory of the Maven installation used to invoke Maven.InvokersetOutputHandler(InvocationOutputHandler outputHandler)Sets the handler used to capture the standard output from the Maven build.InvokersetWorkingDirectory(java.io.File workingDirectory)Sets the working directory for the Maven invocation.
-
-
-
Field Detail
-
ROLE_HINT
public static final java.lang.String ROLE_HINT
- See Also:
- Constant Field Values
-
-
Method Detail
-
execute
public InvocationResult execute(InvocationRequest request) throws MavenInvocationException
Description copied from interface:InvokerExecutes 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:
executein 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
-
getLocalRepositoryDirectory
public java.io.File getLocalRepositoryDirectory()
Description copied from interface:InvokerGets the path to the base directory of the local repository to use for the Maven invocation.- Specified by:
getLocalRepositoryDirectoryin interfaceInvoker- Returns:
- The path to the base directory of the local repository or
nullto use the location from thesettings.xml.
-
getLogger
public InvokerLogger getLogger()
Description copied from interface:InvokerGets the logger used by this invoker to output diagnostic messages.
-
setLocalRepositoryDirectory
public Invoker setLocalRepositoryDirectory(java.io.File localRepositoryDirectory)
Description copied from interface:InvokerSets the path to the base directory of the local repository to use for the Maven invocation.- Specified by:
setLocalRepositoryDirectoryin interfaceInvoker- Parameters:
localRepositoryDirectory- The path to the base directory of the local repository ornullto use the location from thesettings.xml.- Returns:
- This invoker instance.
-
setLogger
public Invoker setLogger(InvokerLogger logger)
Description copied from interface:InvokerSets the logger used by this invoker to output diagnostic messages.
-
getWorkingDirectory
public java.io.File getWorkingDirectory()
Description copied from interface:InvokerGets the working directory for the Maven invocation.- Specified by:
getWorkingDirectoryin interfaceInvoker- Returns:
- The working directory for the Maven invocation or
nullif the working directory is derived from the base directory of the processed POM.
-
setWorkingDirectory
public Invoker setWorkingDirectory(java.io.File workingDirectory)
Description copied from interface:InvokerSets the working directory for the Maven invocation.- Specified by:
setWorkingDirectoryin interfaceInvoker- Parameters:
workingDirectory- The working directory for the Maven invocation, may benullto derive the working directory from the base directory of the processed POM.- Returns:
- This invoker instance.
-
getMavenHome
public java.io.File getMavenHome()
Description copied from interface:InvokerGets the path to the base directory of the Maven installation used to invoke Maven.- Specified by:
getMavenHomein interfaceInvoker- Returns:
- The path to the base directory of the Maven installation or
nullif using the default Maven installation.
-
setMavenHome
public Invoker setMavenHome(java.io.File mavenHome)
Description copied from interface:InvokerSets 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.homeand the environment variableM2_HOME.- Specified by:
setMavenHomein interfaceInvoker- Parameters:
mavenHome- The path to the base directory of the Maven installation, may benullto use the default Maven installation.- Returns:
- This invoker instance.
-
getMavenExecutable
public java.io.File getMavenExecutable()
Description copied from interface:InvokerGet the customized File of the Maven executable.- Specified by:
getMavenExecutablein interfaceInvoker- Returns:
- the custom Maven executable, otherwise
null
-
setMavenExecutable
public Invoker setMavenExecutable(java.io.File mavenExecutable)
Description copied from interface:InvokermavenExecutablecan either be a file relative to ${maven.home}/bin/ or an absolute file.- Specified by:
setMavenExecutablein interfaceInvoker- Parameters:
mavenExecutable- the executable- Returns:
- This invoker instance
-
setErrorHandler
public Invoker setErrorHandler(InvocationOutputHandler errorHandler)
Description copied from interface:InvokerSets the handler used to capture the error output from the Maven build.- Specified by:
setErrorHandlerin interfaceInvoker- Parameters:
errorHandler- The error handler, may benullif the output is not of interest.- Returns:
- This invoker instance.
-
setInputStream
public Invoker setInputStream(java.io.InputStream inputStream)
Description copied from interface:InvokerSets 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:
setInputStreamin interfaceInvoker- Parameters:
inputStream- The input stream used to provide input for the invoked Maven build, may benullif not required.- Returns:
- This invoker instance.
-
setOutputHandler
public Invoker setOutputHandler(InvocationOutputHandler outputHandler)
Description copied from interface:InvokerSets the handler used to capture the standard output from the Maven build.- Specified by:
setOutputHandlerin interfaceInvoker- Parameters:
outputHandler- The output handler, may benullif the output is not of interest.- Returns:
- This invoker instance.
-
-