org.apache.maven.shared.invoker
Class DefaultInvoker

java.lang.Object
  extended by org.apache.maven.shared.invoker.DefaultInvoker
All Implemented Interfaces:
Invoker

@Component(role=Invoker.class,
           hint="default")
public class DefaultInvoker
extends Object
implements Invoker

Class intended to be used by clients who wish to invoke a forked Maven process from their applications

Author:
jdcasey

Field Summary
static String ROLE_HINT
           
 
Fields inherited from interface org.apache.maven.shared.invoker.Invoker
ROLE, userHome
 
Constructor Summary
DefaultInvoker()
           
 
Method Summary
 InvocationResult execute(InvocationRequest request)
          Executes Maven using the parameters specified by the given invocation request.
 File getLocalRepositoryDirectory()
          Gets the path to the base directory of the local repository to use for the Maven invocation.
 InvokerLogger getLogger()
          Gets the logger used by this invoker to output diagnostic messages.
 File getMavenExecutable()
          Get the customized File of the Maven executable.
 File getMavenHome()
          Gets the path to the base directory of the Maven installation used to invoke Maven.
 File getWorkingDirectory()
          Gets the working directory for the Maven invocation.
 Invoker setErrorHandler(InvocationOutputHandler errorHandler)
          Sets the handler used to capture the error output from the Maven build.
 Invoker setInputStream(InputStream inputStream)
          Sets the input stream used to provide input for the invoked Maven build.
 Invoker setLocalRepositoryDirectory(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(File mavenExecutable)
          mavenExecutable can either be a file relative to ${maven.home}/bin/ or an absolute file.
 Invoker setMavenHome(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(File workingDirectory)
          Sets the working directory for the Maven invocation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROLE_HINT

public static final String ROLE_HINT
See Also:
Constant Field Values
Constructor Detail

DefaultInvoker

public DefaultInvoker()
Method Detail

execute

public InvocationResult execute(InvocationRequest request)
                         throws MavenInvocationException
Description copied from interface: Invoker
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 interface Invoker
Parameters:
request - The invocation request to execute, must not be null.
Returns:
The result of the Maven invocation, never null.
Throws:
MavenInvocationException

getLocalRepositoryDirectory

public File getLocalRepositoryDirectory()
Description copied from interface: Invoker
Gets the path to the base directory of the local repository to use for the Maven invocation.

Specified by:
getLocalRepositoryDirectory in interface Invoker
Returns:
The path to the base directory of the local repository or null to use the location from the settings.xml.

getLogger

public InvokerLogger getLogger()
Description copied from interface: Invoker
Gets the logger used by this invoker to output diagnostic messages.

Specified by:
getLogger in interface Invoker
Returns:
The logger used by this invoker to output diagnostic messages, never null.

setLocalRepositoryDirectory

public Invoker setLocalRepositoryDirectory(File localRepositoryDirectory)
Description copied from interface: Invoker
Sets the path to the base directory of the local repository to use for the Maven invocation.

Specified by:
setLocalRepositoryDirectory in interface Invoker
Parameters:
localRepositoryDirectory - The path to the base directory of the local repository or null to use the location from the settings.xml.
Returns:
This invoker instance.

setLogger

public Invoker setLogger(InvokerLogger logger)
Description copied from interface: Invoker
Sets the logger used by this invoker to output diagnostic messages.

Specified by:
setLogger in interface Invoker
Parameters:
logger - The logger used by this invoker to output diagnostic messages, may be null to use a default logger.
Returns:
This invoker instance.

getWorkingDirectory

public File getWorkingDirectory()
Description copied from interface: Invoker
Gets the working directory for the Maven invocation.

Specified by:
getWorkingDirectory in interface Invoker
Returns:
The working directory for the Maven invocation or null if the working directory is derived from the base directory of the processed POM.

setWorkingDirectory

public Invoker setWorkingDirectory(File workingDirectory)
Description copied from interface: Invoker
Sets the working directory for the Maven invocation.

Specified by:
setWorkingDirectory in interface Invoker
Parameters:
workingDirectory - The working directory for the Maven invocation, may be null to derive the working directory from the base directory of the processed POM.
Returns:
This invoker instance.

getMavenHome

public File getMavenHome()
Description copied from interface: Invoker
Gets the path to the base directory of the Maven installation used to invoke Maven.

Specified by:
getMavenHome in interface Invoker
Returns:
The path to the base directory of the Maven installation or null if using the default Maven installation.

setMavenHome

public Invoker setMavenHome(File mavenHome)
Description copied from interface: Invoker
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 property maven.home and the environment variable M2_HOME.

Specified by:
setMavenHome in interface Invoker
Parameters:
mavenHome - The path to the base directory of the Maven installation, may be null to use the default Maven installation.
Returns:
This invoker instance.

getMavenExecutable

public File getMavenExecutable()
Description copied from interface: Invoker
Get the customized File of the Maven executable.

Specified by:
getMavenExecutable in interface Invoker
Returns:
the custom Maven executable, otherwise null

setMavenExecutable

public Invoker setMavenExecutable(File mavenExecutable)
Description copied from interface: Invoker
mavenExecutable can either be a file relative to ${maven.home}/bin/ or an absolute file.

Specified by:
setMavenExecutable in interface Invoker
Parameters:
mavenExecutable - the executable
Returns:
This invoker instance

setErrorHandler

public Invoker setErrorHandler(InvocationOutputHandler errorHandler)
Description copied from interface: Invoker
Sets the handler used to capture the error output from the Maven build.

Specified by:
setErrorHandler in interface Invoker
Parameters:
errorHandler - The error handler, may be null if the output is not of interest.
Returns:
This invoker instance.

setInputStream

public Invoker setInputStream(InputStream inputStream)
Description copied from interface: Invoker
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 interface Invoker
Parameters:
inputStream - The input stream used to provide input for the invoked Maven build, may be null if not required.
Returns:
This invoker instance.

setOutputHandler

public Invoker setOutputHandler(InvocationOutputHandler outputHandler)
Description copied from interface: Invoker
Sets the handler used to capture the standard output from the Maven build.

Specified by:
setOutputHandler in interface Invoker
Parameters:
outputHandler - The output handler, may be null if the output is not of interest.
Returns:
This invoker instance.


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.