Package org.apache.maven.shared.invoker
Class DefaultInvocationRequest
java.lang.Object
org.apache.maven.shared.invoker.DefaultInvocationRequest
- All Implemented Interfaces:
InvocationRequest
Specifies the parameters used to control a Maven invocation.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.maven.shared.invoker.InvocationRequest
InvocationRequest.CheckSumPolicy, InvocationRequest.ReactorFailureBehavior
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private boolean
private File
private String
private boolean
private InvocationOutputHandler
private InvocationRequest.CheckSumPolicy
private File
private File
private InputStream
private boolean
private File
private File
private String
private boolean
private boolean
private InvocationOutputHandler
private File
private String
private Properties
private boolean
private boolean
private String
private boolean
private boolean
private boolean
private String
private int
private File
private boolean
private File
Fields inherited from interface org.apache.maven.shared.invoker.InvocationRequest
NO_TIMEOUT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddShellEnvironment
(String name, String value) Adds the specified environment variable to the Maven invocation.getBaseDirectory.getBaseDirectory
(File defaultDirectory) Gets the path to the base directory of the POM for the Maven invocation.Get the current set builder strategy id equivalent of--builder id
.getErrorHandler
(InvocationOutputHandler defaultHandler) Gets the handler used to capture the error output from the Maven build.Gets the checksum mode of the Maven invocation.Gets the path to the global settings for the Maven invocation.Alternate path for the global toolchains file Note.getGoals()
Getter for the fieldgoals
.getInputStream
(InputStream defaultStream) Gets the input stream used to provide input for the invoked Maven build.Getter for the fieldjavaHome
.getLocalRepositoryDirectory
(File defaultDirectory) Gets the path to the base directory of the local repository to use for the Maven invocation.Getter for the fieldmavenOpts
.getOutputHandler
(InvocationOutputHandler defaultHandler) Gets the handler used to capture the standard output from the Maven build.Getter for the fieldpomFile
.Gets the (unqualified) filename of the POM for the Maven invocation.Gets the profiles for the Maven invocation.A list of specified reactor projects to build instead of all projects.Getter for the fieldproperties
.getReactorFailureBehavior.Get the value ofresume-from
Getter for the fieldshellEnvironments
.Get the value of thethreads
argument.int
getTimeoutInSeconds.Gets the path to the custom toolchains fileGets the path to the user settings for the Maven invocation.boolean
Get the value of thealso-make
argument.boolean
Get the value of thealso-make-dependents
boolean
isBatchMode.boolean
isDebug()
isDebug.boolean
Indicates whether Maven should check for plugin updates.boolean
isOffline.boolean
isQuiet()
Gets the quiet mode of the Maven invocation.boolean
isRecursive.boolean
isShellEnvironmentInherited.boolean
isShowErrors.boolean
isShowVersion.boolean
isUpdateSnapshots.setAlsoMake
(boolean alsoMake) Enable the 'also make' mode.setAlsoMakeDependents
(boolean alsoMakeDependents) Enable the 'also make dependents' mode.setBaseDirectory
(File basedir) Sets the path to the base directory of the POM for the Maven invocation.setBatchMode
(boolean interactive) Sets the interaction mode of the Maven invocation.setBuilder
(String id) The id of the build strategy to use.setDebug
(boolean debug) Sets the debug mode of the Maven invocation.setErrorHandler
(InvocationOutputHandler errorHandler) Sets the handler used to capture the error output from the Maven build.setGlobalChecksumPolicy
(InvocationRequest.CheckSumPolicy globalChecksumPolicy) Sets the checksum mode of the Maven invocation.setGlobalSettingsFile
(File globalSettings) Sets the path to the global settings for the Maven invocation.setGlobalToolchainsFile
(File toolchains) Sets the alternate path for the global toolchains file Equivalent of-gt
or--global-toolchains
Sets the goals for the Maven invocation.setInputStream
(InputStream inputStream) Sets the input stream used to provide input for the invoked Maven build.setJavaHome
(File javaHome) Sets the path to the base directory of the Java installation used to run Maven.setLocalRepositoryDirectory
(File localRepository) Sets the path to the base directory of the local repository to use for the Maven invocation.setMavenOpts
(String mavenOpts) Sets the value of theMAVEN_OPTS
environment variable.setNonPluginUpdates
(boolean nonPluginUpdates) Specifies whether Maven should check for plugin updates.setOffline
(boolean offline) Sets the network mode of the Maven invocation.setOutputHandler
(InvocationOutputHandler outputHandler) Sets the handler used to capture the standard output from the Maven build.setPomFile
(File pomFile) Sets the path to the POM for the Maven invocation.setPomFileName
(String pomFilename) Sets the (unqualified) filename of the POM for the Maven invocation.setProfiles
(List<String> profiles) Sets the profiles for the Maven invocation.setProjects
(List<String> projects) Sets the reactor project list.setProperties
(Properties properties) Sets the system properties for the Maven invocation.setQuiet
(boolean quiet) Sets the quiet mode of the Maven invocation.setReactorFailureBehavior
(InvocationRequest.ReactorFailureBehavior failureBehavior) setReactorFailureBehavior.setRecursive
(boolean recursive) Sets the recursion behavior of a reactor invocation.setResumeFrom
(String resumeFrom) Resume reactor from specified project.setShellEnvironmentInherited
(boolean shellEnvironmentInherited) Specifies whether the environment variables of the current process should be propagated to the Maven invocation.setShowErrors
(boolean showErrors) Sets the exception output mode of the Maven invocation.setShowVersion
(boolean showVersion) enable displaying version without stopping the build Equivalent of-V
or--show-version
setThreads
(String threads) Thread count, for instance 2.0C where C is core multiplied Equivalent of-T
or--threads
void
setTimeoutInSeconds
(int timeoutInSeconds) setTimeoutInSeconds.setToolchainsFile
(File toolchains) Sets the alternate path for the user toolchains file Equivalent of-t
or--toolchains
setUpdateSnapshots
(boolean updateSnapshots) Specifies whether Maven should enforce an update check for plugins and snapshots.setUserSettingsFile
(File userSettings) Sets the path to the user settings for the Maven invocation.
-
Field Details
-
basedir
-
debug
private boolean debug -
errorHandler
-
failureBehavior
-
goals
-
inputStream
-
interactive
private boolean interactive -
localRepository
-
offline
private boolean offline -
recursive
private boolean recursive -
outputHandler
-
pomFile
-
properties
-
showErrors
private boolean showErrors -
updateSnapshots
private boolean updateSnapshots -
shellEnvironmentInherited
private boolean shellEnvironmentInherited -
userSettings
-
globalSettings
-
toolchains
-
globalToolchains
-
globalChecksumPolicy
-
pomFilename
-
javaHome
-
profiles
-
nonPluginUpdates
private boolean nonPluginUpdates -
shellEnvironments
-
mavenOpts
-
projects
-
alsoMake
private boolean alsoMake -
alsoMakeDependents
private boolean alsoMakeDependents -
resumeFrom
-
showVersion
private boolean showVersion -
threads
-
builderId
-
timeoutInSeconds
private int timeoutInSeconds -
quiet
private boolean quiet
-
-
Constructor Details
-
DefaultInvocationRequest
public DefaultInvocationRequest()
-
-
Method Details
-
getBaseDirectory
getBaseDirectory.
- Specified by:
getBaseDirectory
in interfaceInvocationRequest
- Returns:
- a
File
object.
-
getBaseDirectory
Gets the path to the base directory of the POM for the Maven invocation. IfInvocationRequest.getPomFile()
does not returnnull
, this setting only affects the working directory for the Maven invocation.- Specified by:
getBaseDirectory
in interfaceInvocationRequest
- Parameters:
defaultDirectory
- The default base directory to use if none is configured for this request, may benull
.- Returns:
- The path to the base directory of the POM or
null
if not set.
-
getReactorFailureBehavior
getReactorFailureBehavior.
- Specified by:
getReactorFailureBehavior
in interfaceInvocationRequest
- Returns:
- a ReactorFailureBehavior object.
-
getGoals
Getter for the field
goals
.- Specified by:
getGoals
in interfaceInvocationRequest
- Returns:
- a
List
object.
-
getInputStream
Gets 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:
getInputStream
in interfaceInvocationRequest
- Parameters:
defaultStream
- the defaultInputStream
to use- Returns:
- The input stream used to provide input for the invoked Maven build or
null
if not set.
-
getLocalRepositoryDirectory
Gets the path to the base directory of the local repository to use for the Maven invocation.- Specified by:
getLocalRepositoryDirectory
in interfaceInvocationRequest
- Parameters:
defaultDirectory
- The default location to use if no location is configured for this request, may benull
.- Returns:
- The path to the base directory of the local repository or
null
to use the location from thesettings.xml
.
-
getPomFile
Getter for the field
pomFile
.- Specified by:
getPomFile
in interfaceInvocationRequest
- Returns:
- a
File
object.
-
getProperties
Getter for the field
properties
.- Specified by:
getProperties
in interfaceInvocationRequest
- Returns:
- a
Properties
object.
-
isDebug
public boolean isDebug()isDebug.
- Specified by:
isDebug
in interfaceInvocationRequest
- Returns:
- a boolean.
-
isBatchMode
public boolean isBatchMode()isBatchMode.
- Specified by:
isBatchMode
in interfaceInvocationRequest
- Returns:
- a boolean.
-
isOffline
public boolean isOffline()isOffline.
- Specified by:
isOffline
in interfaceInvocationRequest
- Returns:
- a boolean.
-
isShowErrors
public boolean isShowErrors()isShowErrors.
- Specified by:
isShowErrors
in interfaceInvocationRequest
- Returns:
- a boolean.
-
isUpdateSnapshots
public boolean isUpdateSnapshots()isUpdateSnapshots.
- Specified by:
isUpdateSnapshots
in interfaceInvocationRequest
- Returns:
- a boolean.
-
isRecursive
public boolean isRecursive()isRecursive.
- Specified by:
isRecursive
in interfaceInvocationRequest
- Returns:
- a boolean.
-
setRecursive
Sets the recursion behavior of a reactor invocation. Inverse equivalent of-N
and--non-recursive
- Specified by:
setRecursive
in interfaceInvocationRequest
- Parameters:
recursive
-true
if sub modules should be build,false
otherwise.- Returns:
- This invocation request.
-
setBaseDirectory
Sets the path to the base directory of the POM for the Maven invocation. IfInvocationRequest.getPomFile()
does not returnnull
, this setting only affects the working directory for the Maven invocation.- Specified by:
setBaseDirectory
in interfaceInvocationRequest
- Parameters:
basedir
- The path to the base directory of the POM, may benull
if not used.- Returns:
- This invocation request.
-
setDebug
Sets the debug mode of the Maven invocation. Equivalent of-X
and--debug
- Specified by:
setDebug
in interfaceInvocationRequest
- Parameters:
debug
-true
if Maven should be executed in debug mode,false
if the normal mode should be used.- Returns:
- This invocation request.
-
setGoals
Sets the goals for the Maven invocation.- Specified by:
setGoals
in interfaceInvocationRequest
- Parameters:
goals
- The goals for the Maven invocation, may benull
to execute the POMs default goal.- Returns:
- This invocation request.
-
setInputStream
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 interfaceInvocationRequest
- Parameters:
inputStream
- The input stream used to provide input for the invoked Maven build, may benull
if not required.- Returns:
- This invocation request.
-
setBatchMode
Sets the interaction mode of the Maven invocation. Equivalent of-B
and--batch-mode
- Specified by:
setBatchMode
in interfaceInvocationRequest
- Parameters:
interactive
-true
if Maven should be executed in non-interactive mode,false
if the interactive modes is used.- Returns:
- This invocation request.
-
setLocalRepositoryDirectory
Sets the path to the base directory of the local repository to use for the Maven invocation.- Specified by:
setLocalRepositoryDirectory
in interfaceInvocationRequest
- Parameters:
localRepository
- The path to the base directory of the local repository, may benull
.- Returns:
- This invocation request.
-
setOffline
Sets the network mode of the Maven invocation. Equivalent of-o
and--offline
- Specified by:
setOffline
in interfaceInvocationRequest
- Parameters:
offline
-true
if Maven should be executed in offline mode,false
if the online mode is used.- Returns:
- This invocation request.
-
setPomFile
Sets the path to the POM for the Maven invocation. If no base directory is set, the parent directory of this POM will be used as the working directory for the Maven invocation.- Specified by:
setPomFile
in interfaceInvocationRequest
- Parameters:
pomFile
- The path to the POM for the Maven invocation, may benull
if not used.- Returns:
- This invocation request.
-
setProperties
Sets the system properties for the Maven invocation.- Specified by:
setProperties
in interfaceInvocationRequest
- Parameters:
properties
- The system properties for the Maven invocation, may benull
if not set.- Returns:
- This invocation request.
-
setShowErrors
Sets the exception output mode of the Maven invocation. Equivalent of-e
and--errors
- Specified by:
setShowErrors
in interfaceInvocationRequest
- Parameters:
showErrors
-true
if Maven should print stack traces,false
otherwise.- Returns:
- This invocation request.
-
setUpdateSnapshots
Specifies whether Maven should enforce an update check for plugins and snapshots. Equivalent of-U
and--update-snapshots
- Specified by:
setUpdateSnapshots
in interfaceInvocationRequest
- Parameters:
updateSnapshots
-true
if plugins and snapshots should be updated,false
otherwise.- Returns:
- This invocation request.
-
isShellEnvironmentInherited
public boolean isShellEnvironmentInherited()isShellEnvironmentInherited.
- Specified by:
isShellEnvironmentInherited
in interfaceInvocationRequest
- Returns:
- a boolean.
- See Also:
-
setShellEnvironmentInherited
Specifies whether the environment variables of the current process should be propagated to the Maven invocation.- Specified by:
setShellEnvironmentInherited
in interfaceInvocationRequest
- Parameters:
shellEnvironmentInherited
-true
if the environment variables should be propagated,false
otherwise.- Returns:
- This invocation request.
-
getJavaHome
Getter for the field
javaHome
.- Specified by:
getJavaHome
in interfaceInvocationRequest
- Returns:
- a
File
object.
-
setJavaHome
Sets the path to the base directory of the Java installation used to run Maven.- Specified by:
setJavaHome
in interfaceInvocationRequest
- Parameters:
javaHome
- The path to the base directory of the Java installation used to run Maven, may benull
to use the default Java home.- Returns:
- This invocation request.
-
getUserSettingsFile
Gets the path to the user settings for the Maven invocation.- Specified by:
getUserSettingsFile
in interfaceInvocationRequest
- Returns:
- a
File
object.
-
setUserSettingsFile
Sets the path to the user settings for the Maven invocation. Equivalent of-s
and--settings
- Specified by:
setUserSettingsFile
in interfaceInvocationRequest
- Parameters:
userSettings
- The path to the user settings for the Maven invocation, may benull
to load the user settings from the default location.- Returns:
- This invocation request.
-
getGlobalSettingsFile
Gets the path to the global settings for the Maven invocation.- Specified by:
getGlobalSettingsFile
in interfaceInvocationRequest
- Returns:
- a
File
object.
-
setGlobalSettingsFile
Sets the path to the global settings for the Maven invocation. Equivalent of-gs
and--global-settings
- Specified by:
setGlobalSettingsFile
in interfaceInvocationRequest
- Parameters:
globalSettings
- The path to the global settings for the Maven invocation, may benull
to load the global settings from the default location.- Returns:
- This invocation request.
-
getToolchainsFile
Gets the path to the custom toolchains file- Specified by:
getToolchainsFile
in interfaceInvocationRequest
- Returns:
- a
File
object.
-
setToolchainsFile
Sets the alternate path for the user toolchains file Equivalent of-t
or--toolchains
- Specified by:
setToolchainsFile
in interfaceInvocationRequest
- Parameters:
toolchains
- the alternate path for the user toolchains file- Returns:
- This invocation request
-
getGlobalToolchainsFile
Alternate path for the global toolchains file Note. This is available since Maven 3.3.1- Specified by:
getGlobalToolchainsFile
in interfaceInvocationRequest
- Returns:
- a
File
object.
-
setGlobalToolchainsFile
Sets the alternate path for the global toolchains file Equivalent of-gt
or--global-toolchains
- Specified by:
setGlobalToolchainsFile
in interfaceInvocationRequest
- Parameters:
toolchains
- the alternate path for the global toolchains file- Returns:
- This invocation request
-
getGlobalChecksumPolicy
Gets the checksum mode of the Maven invocation.- Specified by:
getGlobalChecksumPolicy
in interfaceInvocationRequest
- Returns:
- a CheckSumPolicy object.
-
getPomFileName
Gets the (unqualified) filename of the POM for the Maven invocation. This setting is ignored ifInvocationRequest.getPomFile()
does not returnnull
. Otherwise, the base directory is assumed to contain a POM with this name. By default, a file namedpom.xml
is used.- Specified by:
getPomFileName
in interfaceInvocationRequest
- Returns:
- a
String
object.
-
setPomFileName
Sets the (unqualified) filename of the POM for the Maven invocation. This setting is ignored ifInvocationRequest.getPomFile()
does not returnnull
. Otherwise, the base directory is assumed to contain a POM with this name.- Specified by:
setPomFileName
in interfaceInvocationRequest
- Parameters:
pomFilename
- The (unqualified) filename of the POM for the Maven invocation, may benull
if not used.- Returns:
- This invocation request.
-
getProfiles
Gets the profiles for the Maven invocation.- Specified by:
getProfiles
in interfaceInvocationRequest
- Returns:
- a
List
object.
-
setProfiles
Sets the profiles for the Maven invocation. Equivalent of-P
and--active-profiles
- Specified by:
setProfiles
in interfaceInvocationRequest
- Parameters:
profiles
- The profiles for the Maven invocation, may benull
to use the default profiles.- Returns:
- This invocation request.
-
isNonPluginUpdates
public boolean isNonPluginUpdates()Indicates whether Maven should check for plugin updates. By default, plugin updates are not suppressed.- Specified by:
isNonPluginUpdates
in interfaceInvocationRequest
- Returns:
- a boolean.
-
setNonPluginUpdates
Specifies whether Maven should check for plugin updates.Equivalent of
-npu
or--no-plugin-updates
note: Ineffective with Maven3, only kept for backward compatibility
- Specified by:
setNonPluginUpdates
in interfaceInvocationRequest
- Parameters:
nonPluginUpdates
-true
if plugin updates should be suppressed,false
otherwise.- Returns:
- This invocation request.
-
addShellEnvironment
Adds the specified environment variable to the Maven invocation.- Specified by:
addShellEnvironment
in interfaceInvocationRequest
- Parameters:
name
- The name of the environment variable, must not benull
.value
- The value of the environment variable, must not benull
.- Returns:
- This invocation request.
-
getShellEnvironments
Getter for the field
shellEnvironments
.- Specified by:
getShellEnvironments
in interfaceInvocationRequest
- Returns:
- a
Map
object.
-
getMavenOpts
Getter for the field
mavenOpts
.- Specified by:
getMavenOpts
in interfaceInvocationRequest
- Returns:
- a
String
object.
-
setMavenOpts
Sets the value of theMAVEN_OPTS
environment variable.- Specified by:
setMavenOpts
in interfaceInvocationRequest
- Parameters:
mavenOpts
- The value of theMAVEN_OPTS
environment variable, may benull
to use the default options.- Returns:
- This invocation request.
-
isShowVersion
public boolean isShowVersion()isShowVersion.
- Specified by:
isShowVersion
in interfaceInvocationRequest
- Returns:
- a boolean.
- See Also:
-
setShowVersion
enable displaying version without stopping the build Equivalent of-V
or--show-version
- Specified by:
setShowVersion
in interfaceInvocationRequest
- Parameters:
showVersion
- enable displaying version- Returns:
- This invocation request.
-
getThreads
Get the value of thethreads
argument.- Specified by:
getThreads
in interfaceInvocationRequest
- Returns:
- a
String
object.
-
setThreads
Thread count, for instance 2.0C where C is core multiplied Equivalent of-T
or--threads
note: available since Maven3
- Specified by:
setThreads
in interfaceInvocationRequest
- Parameters:
threads
- the threadcount- Returns:
- This invocation request.
-
getProjects
A list of specified reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by its relative path.- Specified by:
getProjects
in interfaceInvocationRequest
- Returns:
- a
List
object.
-
setProjects
Sets the reactor project list. Equivalent of-pl
or--projects
- Specified by:
setProjects
in interfaceInvocationRequest
- Parameters:
projects
- the reactor project list- Returns:
- This invocation request.
-
isAlsoMake
public boolean isAlsoMake()Get the value of thealso-make
argument.- Specified by:
isAlsoMake
in interfaceInvocationRequest
- Returns:
- a boolean.
-
setAlsoMake
Enable the 'also make' mode. Equivalent of-am
or--also-make
- Specified by:
setAlsoMake
in interfaceInvocationRequest
- Parameters:
alsoMake
- enable 'also make' mode- Returns:
- This invocation request.
-
isAlsoMakeDependents
public boolean isAlsoMakeDependents()Get the value of thealso-make-dependents
- Specified by:
isAlsoMakeDependents
in interfaceInvocationRequest
- Returns:
- a boolean.
-
setAlsoMakeDependents
Enable the 'also make dependents' mode. Equivalent of-amd
or--also-make-dependents
- Specified by:
setAlsoMakeDependents
in interfaceInvocationRequest
- Parameters:
alsoMakeDependents
- enable 'also make' mode- Returns:
- This invocation request.
-
getResumeFrom
Get the value ofresume-from
- Specified by:
getResumeFrom
in interfaceInvocationRequest
- Returns:
- a
String
object.
-
setResumeFrom
Resume reactor from specified project. Equivalent of-rf
or--resume-from
- Specified by:
setResumeFrom
in interfaceInvocationRequest
- Parameters:
resumeFrom
- set the project to resume from- Returns:
- This invocation request
-
setBuilder
The id of the build strategy to use. equivalent of--builder id
. Note. This is available since Maven 3.2.1- Specified by:
setBuilder
in interfaceInvocationRequest
- Parameters:
id
- The builder id.- Returns:
InvocationRequest
FIXME: How to identify if this is a valid command line option?
-
getBuilder
Get the current set builder strategy id equivalent of--builder id
. Note. This is available since Maven 3.2.1- Specified by:
getBuilder
in interfaceInvocationRequest
- Returns:
- a
String
object.
-
getTimeoutInSeconds
public int getTimeoutInSeconds()getTimeoutInSeconds.
- Specified by:
getTimeoutInSeconds
in interfaceInvocationRequest
- Returns:
- the timeout in seconds to execute the project
-
setTimeoutInSeconds
public void setTimeoutInSeconds(int timeoutInSeconds) setTimeoutInSeconds.
- Specified by:
setTimeoutInSeconds
in interfaceInvocationRequest
- Parameters:
timeoutInSeconds
- the timeout in seconds to execute the project
-
isQuiet
public boolean isQuiet()Gets the quiet mode of the Maven invocation. By default, Maven is executed in normal mode.- Specified by:
isQuiet
in interfaceInvocationRequest
- Returns:
- a boolean.
- Since:
- 3.1.0
-
setQuiet
Sets the quiet mode of the Maven invocation. Equivalent of-q
and--quiet
- Specified by:
setQuiet
in interfaceInvocationRequest
- Parameters:
quiet
-true
if Maven should be executed in quiet mode,false
if the normal mode should be used.- Returns:
- This invocation request.
-