Package org.apache.maven.shared.invoker
Interface InvocationRequest
- All Known Implementing Classes:
DefaultInvocationRequest
public interface InvocationRequest
Specifies the parameters used to control a Maven invocation.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The kind of checksum policy which should be used during Maven invocation.static enum
The reactor failure behavior which to be used during Maven invocation. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdd a raw argument to Maven cli command at the end of other arguments.addArgs
(Collection<String> args) Add a raw arguments list to Maven cli command at the end of other arguments.addShellEnvironment
(String name, String value) Adds the specified environment variable to the Maven invocation.getArgs()
List of raw line arguments which will be passed to cli.Gets the path to the base directory of the POM for the Maven invocation.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()
Gets the goals for the Maven invocation.getInputStream
(InputStream defaultStream) Gets the input stream used to provide input for the invoked Maven build.Gets the path to the base directory of the Java installation used to run Maven.getLocalRepositoryDirectory
(File defaultDirectory) Gets the path to the base directory of the local repository to use for the Maven invocation.Get the customized File of the Maven executable.Gets the path to the base directory of the Maven installation used to invoke Maven.Gets the value of theMAVEN_OPTS
environment variable.getOutputHandler
(InvocationOutputHandler defaultHandler) Gets the handler used to capture the standard output from the Maven build.Gets the path to the POM for the Maven invocation.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.Gets the system properties for the Maven invocation.Gets the failure mode of the Maven invocation.Get the value ofresume-from
Gets the environment variables for the Maven invocation.Get the value of thethreads
argument.int
getTimeoutInSeconds.Gets the path to the custom toolchains fileIndicates the update snapshots policy.Gets 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
By default, Maven is executed in batch mode.boolean
isDebug()
Gets the debug mode of the Maven invocation.boolean
Indicates whether Maven should check for plugin updates.boolean
Get the value of theno-transfer-progress
argument.boolean
Gets the network mode of the Maven invocation.boolean
isQuiet()
Gets the quiet mode of the Maven invocation.boolean
Gets the recursion behavior of a reactor invocation.boolean
Indicates whether the environment variables of the current process should be propagated to the Maven invocation.boolean
Gets the exception output mode of the Maven invocation.boolean
The show version behavior (-V option)boolean
Indicates whether Maven should enforce an update check for plugins and snapshots.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 batchMode) 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
Deprecated.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.setMavenExecutable
(File mavenExecutable) mavenExecutable
can either be a file relative to ${maven.home}/bin/ or an absolute file.setMavenHome
(File mavenHome) Sets the path to the base directory of the Maven installation used to invoke Maven.setMavenOpts
(String mavenOpts) Sets the value of theMAVEN_OPTS
environment variable.setNonPluginUpdates
(boolean nonPluginUpdates) Specifies whether Maven should check for plugin updates.setNoTransferProgress
(boolean noTransferProgress) Enable no transfer progress mode.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) Sets the failure mode of the Maven invocation.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.Specify the Maven update snapshots policysetUserSettingsFile
(File userSettings) Sets the path to the user settings for the Maven invocation.
-
Field Details
-
NO_TIMEOUT
static final int NO_TIMEOUTConstantNO_TIMEOUT=0
- See Also:
-
-
Method Details
-
isBatchMode
boolean isBatchMode()By default, Maven is executed in batch mode. This mean no interaction with the Maven process can be done.- Returns:
true
if Maven should be executed in batch mode,false
if Maven is executed in interactive mode.- Since:
- 3.0.0
-
isOffline
boolean isOffline()Gets the network mode of the Maven invocation. By default, Maven is executed in online mode.- Returns:
true
if Maven should be executed in offline mode,false
if the online mode is used.
-
isUpdateSnapshots
boolean isUpdateSnapshots()Indicates whether Maven should enforce an update check for plugins and snapshots. By default, no update check is performed.- Returns:
true
if plugins and snapshots must be updated,false
otherwise.- See Also:
-
getUpdateSnapshotsPolicy
UpdateSnapshotsPolicy getUpdateSnapshotsPolicy()Indicates the update snapshots policy.- Returns:
- the update snapshots policy.
- See Also:
-
isRecursive
boolean isRecursive()Gets the recursion behavior of a reactor invocation. By default, Maven will recursive the build into sub modules.- Returns:
true
if sub modules should be build,false
otherwise.
-
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.- Returns:
- the list of projects to add to reactor build, otherwise
null
- Since:
- 2.1
-
isAlsoMake
boolean isAlsoMake()Get the value of thealso-make
argument.- Returns:
true
if the argumentalso-make
was specified, otherwisefalse
- Since:
- 2.1
-
isAlsoMakeDependents
boolean isAlsoMakeDependents()Get the value of thealso-make-dependents
- Returns:
true
if the argumentalso-make-dependents
was specified, otherwisefalse
- Since:
- 2.1
-
getResumeFrom
String getResumeFrom()Get the value ofresume-from
- Returns:
- specified reactor project to resume from
- Since:
- 2.1
-
isDebug
boolean isDebug()Gets the debug mode of the Maven invocation. By default, Maven is executed in normal mode.- Returns:
true
if Maven should be executed in debug mode,false
if the normal mode should be used.
-
isShowErrors
boolean isShowErrors()Gets the exception output mode of the Maven invocation. By default, Maven will not print stack traces of build exceptions.- Returns:
true
if Maven should print stack traces,false
otherwise.
-
isShellEnvironmentInherited
boolean isShellEnvironmentInherited()Indicates whether the environment variables of the current process should be propagated to the Maven invocation. By default, the current environment variables are inherited by the new Maven invocation.- Returns:
true
if the environment variables should be propagated,false
otherwise.
-
isNonPluginUpdates
boolean isNonPluginUpdates()Indicates whether Maven should check for plugin updates. By default, plugin updates are not suppressed.- Returns:
true
if plugin updates should be suppressed,false
otherwise.
-
getReactorFailureBehavior
InvocationRequest.ReactorFailureBehavior getReactorFailureBehavior()Gets the failure mode of the Maven invocation. By default, the modeInvocationRequest.ReactorFailureBehavior.FailFast
is used.- Returns:
- The failure mode, one of
InvocationRequest.ReactorFailureBehavior.FailFast
,InvocationRequest.ReactorFailureBehavior.FailAtEnd
andInvocationRequest.ReactorFailureBehavior.FailNever
. - Since:
- 3.0.0
-
getLocalRepositoryDirectory
Gets the path to the base directory of the local repository to use for the Maven invocation.- 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
.
-
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.- Parameters:
defaultStream
- the defaultInputStream
to use- Returns:
- The input stream used to provide input for the invoked Maven build or
null
if not set.
-
getPomFile
File getPomFile()Gets 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.- Returns:
- The path to the POM for the Maven invocation or
null
if not set.
-
getPomFileName
String getPomFileName()Gets the (unqualified) filename of the POM for the Maven invocation. This setting is ignored ifgetPomFile()
does not returnnull
. Otherwise, the base directory is assumed to contain a POM with this name. By default, a file namedpom.xml
is used.- Returns:
- The (unqualified) filename of the POM for the Maven invocation or
null
if not set.
-
getArgs
List of raw line arguments which will be passed to cli.- Returns:
- a list of cli arguments
- Since:
- 3.2.0
-
getBaseDirectory
File getBaseDirectory()Gets the path to the base directory of the POM for the Maven invocation. IfgetPomFile()
does not returnnull
, this setting only affects the working directory for the Maven invocation.- Returns:
- The path to the base directory of the POM or
null
if not set.
-
getBaseDirectory
Gets the path to the base directory of the POM for the Maven invocation. IfgetPomFile()
does not returnnull
, this setting only affects the working directory for the Maven invocation.- 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.
-
getJavaHome
File getJavaHome()Gets the path to the base directory of the Java installation used to run Maven.- Returns:
- The path to the base directory of the Java installation used to run Maven or
null
to use the default Java home.
-
getProperties
Properties getProperties()Gets the system properties for the Maven invocation.- Returns:
- The system properties for the Maven invocation or
null
if not set.
-
getGoals
Gets the goals for the Maven invocation.- Returns:
- The goals for the Maven invocation or
null
if not set.
-
getUserSettingsFile
File getUserSettingsFile()Gets the path to the user settings for the Maven invocation.- Returns:
- The path to the user settings for the Maven invocation or
null
to load the user settings from the default location.
-
getGlobalSettingsFile
File getGlobalSettingsFile()Gets the path to the global settings for the Maven invocation.- Returns:
- The path to the global settings for the Maven invocation or
null
to load the global settings from the default location. - Since:
- 2.1
-
getToolchainsFile
File getToolchainsFile()Gets the path to the custom toolchains file- Returns:
- The path to the custom toolchains file or
null
to load the toolchains from the default location - Since:
- 2.1
-
getGlobalToolchainsFile
File getGlobalToolchainsFile()Alternate path for the global toolchains file Note. This is available since Maven 3.3.1- Returns:
- The path to the custom global toolchains file or
null
to load the global toolchains from the default location. - Since:
- 3.0.0
-
getGlobalChecksumPolicy
InvocationRequest.CheckSumPolicy getGlobalChecksumPolicy()Gets the checksum mode of the Maven invocation.- Returns:
- The checksum mode, one of
InvocationRequest.CheckSumPolicy.Warn
andInvocationRequest.CheckSumPolicy.Fail
. - Since:
- 3.0.0
-
getProfiles
Gets the profiles for the Maven invocation.- Returns:
- The profiles for the Maven invocation or
null
if not set.
-
getShellEnvironments
Gets the environment variables for the Maven invocation.- Returns:
- The environment variables for the Maven invocation or
null
if not set.
-
getMavenOpts
String getMavenOpts()Gets the value of theMAVEN_OPTS
environment variable.- Returns:
- The value of the
MAVEN_OPTS
environment variable ornull
if not set.
-
isShowVersion
boolean isShowVersion()The show version behavior (-V option)- Returns:
- The show version behavior
- Since:
- 2.0.11
-
getThreads
String getThreads()Get the value of thethreads
argument.- Returns:
- the value of the
threads
argument ornull
if not set - Since:
- 2.1
-
isQuiet
boolean isQuiet()Gets the quiet mode of the Maven invocation. By default, Maven is executed in normal mode.- Returns:
true
if Maven should be executed in quiet mode,false
if normal mode should be used.- Since:
- 3.1.0
-
isNoTransferProgress
boolean isNoTransferProgress()Get the value of theno-transfer-progress
argument.- Returns:
true
if the argumentno-transfer-progress
was specified, otherwisefalse
- Since:
- 3.2.0
-
setBatchMode
Sets the interaction mode of the Maven invocation. Equivalent of-B
and--batch-mode
- Parameters:
batchMode
-true
if Maven should be executed in non-interactive mode,false
if the interactive modes is used.- Returns:
- This invocation request.
- Since:
- 3.0.0
-
setOffline
Sets the network mode of the Maven invocation. Equivalent of-o
and--offline
- Parameters:
offline
-true
if Maven should be executed in offline mode,false
if the online mode is used.- Returns:
- This invocation request.
-
setDebug
Sets the debug mode of the Maven invocation. Equivalent of-X
and--debug
- Parameters:
debug
-true
if Maven should be executed in debug mode,false
if the normal mode should be used.- Returns:
- This invocation request.
-
setShowErrors
Sets the exception output mode of the Maven invocation. Equivalent of-e
and--errors
- 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
- Parameters:
updateSnapshots
-true
if plugins and snapshots must be updated,false
otherwise.- Returns:
- This invocation request.
- See Also:
-
setLocalRepositoryDirectory
Sets the path to the base directory of the local repository to use for the Maven invocation.- Parameters:
localRepository
- The path to the base directory of the local repository, may benull
.- 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.- Parameters:
inputStream
- The input stream used to provide input for the invoked Maven build, may benull
if not required.- 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.- Parameters:
pomFile
- The path to the POM for the Maven invocation, may benull
if not used.- Returns:
- This invocation request.
-
setPomFileName
Sets the (unqualified) filename of the POM for the Maven invocation. This setting is ignored ifgetPomFile()
does not returnnull
. Otherwise, the base directory is assumed to contain a POM with this name.- Parameters:
pomFilename
- The (unqualified) filename of the POM for the Maven invocation, may benull
if not used.- Returns:
- This invocation request.
-
addArg
Add a raw argument to Maven cli command at the end of other arguments. Can be called multiple time in order to add many arguments.- Parameters:
arg
- a raw Maven arg line- Returns:
- This invocation request.
- Since:
- 3.2.0
-
addArgs
Add a raw arguments list to Maven cli command at the end of other arguments. Can be called multiple time in order to add many arguments.- Parameters:
args
- a raw Maven args line- Returns:
- This invocation request.
- Since:
- 3.3.0
-
setBaseDirectory
Sets the path to the base directory of the POM for the Maven invocation. IfgetPomFile()
does not returnnull
, this setting only affects the working directory for the Maven invocation.- Parameters:
basedir
- The path to the base directory of the POM, may benull
if not used.- Returns:
- This invocation request.
-
setJavaHome
Sets the path to the base directory of the Java installation used to run Maven.- 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.
-
setProperties
Sets the system properties for the Maven invocation.- Parameters:
properties
- The system properties for the Maven invocation, may benull
if not set.- Returns:
- This invocation request.
-
setGoals
Deprecated.simplyaddArg(String)
oraddArgs(Collection)
should be usedSets the goals for the Maven invocation.- Parameters:
goals
- The goals for the Maven invocation, may benull
to execute the POMs default goal.- Returns:
- This invocation request.
-
setProfiles
Sets the profiles for the Maven invocation. Equivalent of-P
and--active-profiles
- Parameters:
profiles
- The profiles for the Maven invocation, may benull
to use the default profiles.- Returns:
- This invocation request.
-
setShellEnvironmentInherited
Specifies whether the environment variables of the current process should be propagated to the Maven invocation.- Parameters:
shellEnvironmentInherited
-true
if the environment variables should be propagated,false
otherwise.- Returns:
- This invocation request.
-
setUserSettingsFile
Sets the path to the user settings for the Maven invocation. Equivalent of-s
and--settings
- 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.
-
setGlobalSettingsFile
Sets the path to the global settings for the Maven invocation. Equivalent of-gs
and--global-settings
- 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.
- Since:
- 2.1
-
setToolchainsFile
Sets the alternate path for the user toolchains file Equivalent of-t
or--toolchains
- Parameters:
toolchains
- the alternate path for the user toolchains file- Returns:
- This invocation request
- Since:
- 2.1
-
setGlobalToolchainsFile
Sets the alternate path for the global toolchains file Equivalent of-gt
or--global-toolchains
- Parameters:
toolchains
- the alternate path for the global toolchains file- Returns:
- This invocation request
- Since:
- 3.0.0
-
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
- Parameters:
nonPluginUpdates
-true
if plugin updates should be suppressed,false
otherwise.- Returns:
- This invocation request.
-
setRecursive
Sets the recursion behavior of a reactor invocation. Inverse equivalent of-N
and--non-recursive
- Parameters:
recursive
-true
if sub modules should be build,false
otherwise.- Returns:
- This invocation request.
-
addShellEnvironment
Adds the specified environment variable to the Maven invocation.- 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.
-
setMavenOpts
Sets the value of theMAVEN_OPTS
environment variable.- Parameters:
mavenOpts
- The value of theMAVEN_OPTS
environment variable, may benull
to use the default options.- Returns:
- This invocation request.
-
setShowVersion
enable displaying version without stopping the build Equivalent of-V
or--show-version
- Parameters:
showVersion
- enable displaying version- Returns:
- This invocation request.
- Since:
- 2.0.11
-
setThreads
Thread count, for instance 2.0C where C is core multiplied Equivalent of-T
or--threads
note: available since Maven3
- Parameters:
threads
- the threadcount- Returns:
- This invocation request.
- Since:
- 2.1
-
setProjects
Sets the reactor project list. Equivalent of-pl
or--projects
- Parameters:
projects
- the reactor project list- Returns:
- This invocation request.
- Since:
- 2.1
-
setAlsoMake
Enable the 'also make' mode. Equivalent of-am
or--also-make
- Parameters:
alsoMake
- enable 'also make' mode- Returns:
- This invocation request.
- Since:
- 2.1
-
setAlsoMakeDependents
Enable the 'also make dependents' mode. Equivalent of-amd
or--also-make-dependents
- Parameters:
alsoMakeDependents
- enable 'also make' mode- Returns:
- This invocation request.
- Since:
- 2.1
-
setResumeFrom
Resume reactor from specified project. Equivalent of-rf
or--resume-from
- Parameters:
resumeFrom
- set the project to resume from- Returns:
- This invocation request
- Since:
- 2.1
-
setBuilder
The id of the build strategy to use. equivalent of-b id
or--builder id
. Note. This is available since Maven 3.2.1- Parameters:
id
- The builder id.- Returns:
InvocationRequest
- Since:
- 3.0.0
-
setQuiet
Sets the quiet mode of the Maven invocation. Equivalent of-q
and--quiet
- Parameters:
quiet
-true
if Maven should be executed in quiet mode,false
if the normal mode should be used.- Returns:
- This invocation request.
- Since:
- 3.1.0
-
setNoTransferProgress
Enable no transfer progress mode. Equivalent of-ntp
or--no-transfer-progress
- Parameters:
noTransferProgress
- enable no transfer progress mode- Returns:
- This invocation request.
- Since:
- 3.2.0
-
getBuilder
String getBuilder()Get the current set builder strategy id equivalent of--builder id
. Note. This is available since Maven 3.2.1- Returns:
- The current set builder id.
- Since:
- 3.0.0
-
getTimeoutInSeconds
int getTimeoutInSeconds()getTimeoutInSeconds.
- Returns:
- the timeout in seconds to execute the project
- Since:
- 3.0.1
-
setTimeoutInSeconds
void setTimeoutInSeconds(int timeoutInSeconds) setTimeoutInSeconds.
- Parameters:
timeoutInSeconds
- the timeout in seconds to execute the project- Since:
- 3.0.1
-
getMavenHome
File getMavenHome()Gets the path to the base directory of the Maven installation used to invoke Maven.- Returns:
- The path to the base directory of the Maven installation or
null
if using the default Maven installation. - Since:
- 3.2.0
-
setMavenHome
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
.- Parameters:
mavenHome
- The path to the base directory of the Maven installation, may benull
to use the default Maven installation.- Returns:
- This invocation request
- Since:
- 3.2.0
-
getMavenExecutable
File getMavenExecutable()Get the customized File of the Maven executable.- Returns:
- the custom Maven executable, otherwise
null
- Since:
- 3.2.0
-
setMavenExecutable
mavenExecutable
can either be a file relative to ${maven.home}/bin/ or an absolute file.- Parameters:
mavenExecutable
- the executable- Returns:
- This invocation request
- Since:
- 3.2.0
-
addArg(String)
oraddArgs(Collection)
should be used