Class DefaultInvocationRequest

  • All Implemented Interfaces:
    InvocationRequest

    public class DefaultInvocationRequest
    extends java.lang.Object
    implements InvocationRequest
    Specifies the parameters used to control a Maven invocation.
    Version:
    $Id: DefaultInvocationRequest.java 1666746 2015-03-14 21:06:58Z rfscholte $
    • Field Detail

      • basedir

        private java.io.File basedir
      • debug

        private boolean debug
      • failureBehavior

        private java.lang.String failureBehavior
      • goals

        private java.util.List<java.lang.String> goals
      • inputStream

        private java.io.InputStream inputStream
      • interactive

        private boolean interactive
      • localRepository

        private java.io.File localRepository
      • offline

        private boolean offline
      • recursive

        private boolean recursive
      • pomFile

        private java.io.File pomFile
      • properties

        private java.util.Properties properties
      • showErrors

        private boolean showErrors
      • updateSnapshots

        private boolean updateSnapshots
      • shellEnvironmentInherited

        private boolean shellEnvironmentInherited
      • userSettings

        private java.io.File userSettings
      • globalSettings

        private java.io.File globalSettings
      • toolchains

        private java.io.File toolchains
      • globalChecksumPolicy

        private java.lang.String globalChecksumPolicy
      • pomFilename

        private java.lang.String pomFilename
      • javaHome

        private java.io.File javaHome
      • profiles

        private java.util.List<java.lang.String> profiles
      • nonPluginUpdates

        private boolean nonPluginUpdates
      • shellEnvironments

        private java.util.Map<java.lang.String,​java.lang.String> shellEnvironments
      • mavenOpts

        private java.lang.String mavenOpts
      • activatedReactor

        private boolean activatedReactor
      • activatedReactorIncludes

        private java.lang.String[] activatedReactorIncludes
      • activatedReactorExcludes

        private java.lang.String[] activatedReactorExcludes
      • projects

        private java.util.List<java.lang.String> projects
      • alsoMake

        private boolean alsoMake
      • alsoMakeDependents

        private boolean alsoMakeDependents
      • resumeFrom

        private java.lang.String resumeFrom
      • showVersion

        private boolean showVersion
      • threads

        private java.lang.String threads
    • Constructor Detail

      • DefaultInvocationRequest

        public DefaultInvocationRequest()
    • Method Detail

      • activateReactor

        public InvocationRequest activateReactor​(java.lang.String[] includes,
                                                 java.lang.String[] excludes)
        Description copied from interface: InvocationRequest
        Dynamically constructs a reactor using the subdirectories of the current directory
        Specified by:
        activateReactor in interface InvocationRequest
        Parameters:
        includes - a list of filename patterns to include, or null, in which case the default is */pom.xml
        excludes - a list of filename patterns to exclude, or null, in which case nothing is excluded
        Returns:
        This invocation request
      • getBaseDirectory

        public java.io.File getBaseDirectory()
        Description copied from interface: InvocationRequest
        Gets the path to the base directory of the POM for the Maven invocation. If InvocationRequest.getPomFile() does not return null, this setting only affects the working directory for the Maven invocation.
        Specified by:
        getBaseDirectory in interface InvocationRequest
        Returns:
        The path to the base directory of the POM or null if not set.
      • getBaseDirectory

        public java.io.File getBaseDirectory​(java.io.File defaultDirectory)
        Description copied from interface: InvocationRequest
        Gets the path to the base directory of the POM for the Maven invocation. If InvocationRequest.getPomFile() does not return null, this setting only affects the working directory for the Maven invocation.
        Specified by:
        getBaseDirectory in interface InvocationRequest
        Parameters:
        defaultDirectory - The default base directory to use if none is configured for this request, may be null.
        Returns:
        The path to the base directory of the POM or null if not set.
      • getGoals

        public java.util.List<java.lang.String> getGoals()
        Description copied from interface: InvocationRequest
        Gets the goals for the Maven invocation.
        Specified by:
        getGoals in interface InvocationRequest
        Returns:
        The goals for the Maven invocation or null if not set.
      • getInputStream

        public java.io.InputStream getInputStream​(java.io.InputStream defaultStream)
        Description copied from interface: InvocationRequest
        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 interface InvocationRequest
        Returns:
        The input stream used to provide input for the invoked Maven build or null if not set.
      • getLocalRepositoryDirectory

        public java.io.File getLocalRepositoryDirectory​(java.io.File defaultDirectory)
        Description copied from interface: InvocationRequest
        Gets the path to the base directory of the local repository to use for the Maven invocation.
        Specified by:
        getLocalRepositoryDirectory in interface InvocationRequest
        Parameters:
        defaultDirectory - The default location to use if no location is configured for this request, may be null.
        Returns:
        The path to the base directory of the local repository or null to use the location from the settings.xml.
      • getPomFile

        public java.io.File getPomFile()
        Description copied from interface: InvocationRequest
        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.
        Specified by:
        getPomFile in interface InvocationRequest
        Returns:
        The path to the POM for the Maven invocation or null if not set.
      • getProperties

        public java.util.Properties getProperties()
        Description copied from interface: InvocationRequest
        Gets the system properties for the Maven invocation.
        Specified by:
        getProperties in interface InvocationRequest
        Returns:
        The system properties for the Maven invocation or null if not set.
      • isDebug

        public boolean isDebug()
        Description copied from interface: InvocationRequest
        Gets the debug mode of the Maven invocation. By default, Maven is executed in normal mode.
        Specified by:
        isDebug in interface InvocationRequest
        Returns:
        true if Maven should be executed in debug mode, false if the normal mode should be used.
      • isInteractive

        public boolean isInteractive()
        Description copied from interface: InvocationRequest
        Gets the interaction mode of the Maven invocation. By default, Maven is executed in batch mode.
        Specified by:
        isInteractive in interface InvocationRequest
        Returns:
        true if Maven should be executed in interactive mode, false if the batch mode is used.
      • isOffline

        public boolean isOffline()
        Description copied from interface: InvocationRequest
        Gets the network mode of the Maven invocation. By default, Maven is executed in online mode.
        Specified by:
        isOffline in interface InvocationRequest
        Returns:
        true if Maven should be executed in offline mode, false if the online mode is used.
      • isShowErrors

        public boolean isShowErrors()
        Description copied from interface: InvocationRequest
        Gets the exception output mode of the Maven invocation. By default, Maven will not print stack traces of build exceptions.
        Specified by:
        isShowErrors in interface InvocationRequest
        Returns:
        true if Maven should print stack traces, false otherwise.
      • isUpdateSnapshots

        public boolean isUpdateSnapshots()
        Description copied from interface: InvocationRequest
        Indicates whether Maven should enforce an update check for plugins and snapshots. By default, no update check is performed.
        Specified by:
        isUpdateSnapshots in interface InvocationRequest
        Returns:
        true if plugins and snapshots should be updated, false otherwise.
      • isRecursive

        public boolean isRecursive()
        Description copied from interface: InvocationRequest
        Gets the recursion behavior of a reactor invocation. By default, Maven will recursive the build into sub modules.
        Specified by:
        isRecursive in interface InvocationRequest
        Returns:
        true if sub modules should be build, false otherwise.
      • setRecursive

        public InvocationRequest setRecursive​(boolean recursive)
        Description copied from interface: InvocationRequest
        Sets the recursion behavior of a reactor invocation. Inverse equivalent of -N and --non-recursive
        Specified by:
        setRecursive in interface InvocationRequest
        Parameters:
        recursive - true if sub modules should be build, false otherwise.
        Returns:
        This invocation request.
      • setBaseDirectory

        public InvocationRequest setBaseDirectory​(java.io.File basedir)
        Description copied from interface: InvocationRequest
        Sets the path to the base directory of the POM for the Maven invocation. If InvocationRequest.getPomFile() does not return null, this setting only affects the working directory for the Maven invocation.
        Specified by:
        setBaseDirectory in interface InvocationRequest
        Parameters:
        basedir - The path to the base directory of the POM, may be null if not used.
        Returns:
        This invocation request.
      • setDebug

        public InvocationRequest setDebug​(boolean debug)
        Description copied from interface: InvocationRequest
        Sets the debug mode of the Maven invocation. Equivalent of -X and --debug
        Specified by:
        setDebug in interface InvocationRequest
        Parameters:
        debug - true if Maven should be executed in debug mode, false if the normal mode should be used.
        Returns:
        This invocation request.
      • setGoals

        public InvocationRequest setGoals​(java.util.List<java.lang.String> goals)
        Description copied from interface: InvocationRequest
        Sets the goals for the Maven invocation.
        Specified by:
        setGoals in interface InvocationRequest
        Parameters:
        goals - The goals for the Maven invocation, may be null to execute the POMs default goal.
        Returns:
        This invocation request.
      • setInputStream

        public InvocationRequest setInputStream​(java.io.InputStream inputStream)
        Description copied from interface: InvocationRequest
        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 InvocationRequest
        Parameters:
        inputStream - The input stream used to provide input for the invoked Maven build, may be null if not required.
        Returns:
        This invocation request.
      • setInteractive

        public InvocationRequest setInteractive​(boolean interactive)
        Description copied from interface: InvocationRequest
        Sets the interaction mode of the Maven invocation. Inverse equivalent of -B and --batch-mode
        Specified by:
        setInteractive in interface InvocationRequest
        Parameters:
        interactive - true if Maven should be executed in interactive mode, false if the batch mode is used.
        Returns:
        This invocation request.
      • setLocalRepositoryDirectory

        public InvocationRequest setLocalRepositoryDirectory​(java.io.File localRepository)
        Description copied from interface: InvocationRequest
        Sets the path to the base directory of the local repository to use for the Maven invocation.
        Specified by:
        setLocalRepositoryDirectory in interface InvocationRequest
        Parameters:
        localRepository - The path to the base directory of the local repository, may be null.
        Returns:
        This invocation request.
      • setOffline

        public InvocationRequest setOffline​(boolean offline)
        Description copied from interface: InvocationRequest
        Sets the network mode of the Maven invocation. Equivalent of -o and --offline
        Specified by:
        setOffline in interface InvocationRequest
        Parameters:
        offline - true if Maven should be executed in offline mode, false if the online mode is used.
        Returns:
        This invocation request.
      • setPomFile

        public InvocationRequest setPomFile​(java.io.File pomFile)
        Description copied from interface: InvocationRequest
        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 interface InvocationRequest
        Parameters:
        pomFile - The path to the POM for the Maven invocation, may be null if not used.
        Returns:
        This invocation request.
      • setProperties

        public InvocationRequest setProperties​(java.util.Properties properties)
        Description copied from interface: InvocationRequest
        Sets the system properties for the Maven invocation.
        Specified by:
        setProperties in interface InvocationRequest
        Parameters:
        properties - The system properties for the Maven invocation, may be null if not set.
        Returns:
        This invocation request.
      • setShowErrors

        public InvocationRequest setShowErrors​(boolean showErrors)
        Description copied from interface: InvocationRequest
        Sets the exception output mode of the Maven invocation. Equivalent of -e and --errors
        Specified by:
        setShowErrors in interface InvocationRequest
        Parameters:
        showErrors - true if Maven should print stack traces, false otherwise.
        Returns:
        This invocation request.
      • setUpdateSnapshots

        public InvocationRequest setUpdateSnapshots​(boolean updateSnapshots)
        Description copied from interface: InvocationRequest
        Specifies whether Maven should enforce an update check for plugins and snapshots. Equivalent of -U and --update-snapshots
        Specified by:
        setUpdateSnapshots in interface InvocationRequest
        Parameters:
        updateSnapshots - true if plugins and snapshots should be updated, false otherwise.
        Returns:
        This invocation request.
      • setShellEnvironmentInherited

        public InvocationRequest setShellEnvironmentInherited​(boolean shellEnvironmentInherited)
        Description copied from interface: InvocationRequest
        Specifies whether the environment variables of the current process should be propagated to the Maven invocation.
        Specified by:
        setShellEnvironmentInherited in interface InvocationRequest
        Parameters:
        shellEnvironmentInherited - true if the environment variables should be propagated, false otherwise.
        Returns:
        This invocation request.
      • getJavaHome

        public java.io.File getJavaHome()
        Description copied from interface: InvocationRequest
        Gets the path to the base directory of the Java installation used to run Maven.
        Specified by:
        getJavaHome in interface InvocationRequest
        Returns:
        The path to the base directory of the Java installation used to run Maven or null to use the default Java home.
      • setJavaHome

        public InvocationRequest setJavaHome​(java.io.File javaHome)
        Description copied from interface: InvocationRequest
        Sets the path to the base directory of the Java installation used to run Maven.
        Specified by:
        setJavaHome in interface InvocationRequest
        Parameters:
        javaHome - The path to the base directory of the Java installation used to run Maven, may be null to use the default Java home.
        Returns:
        This invocation request.
      • getUserSettingsFile

        public java.io.File getUserSettingsFile()
        Description copied from interface: InvocationRequest
        Gets the path to the user settings for the Maven invocation.
        Specified by:
        getUserSettingsFile in interface InvocationRequest
        Returns:
        The path to the user settings for the Maven invocation or null to load the user settings from the default location.
      • setUserSettingsFile

        public InvocationRequest setUserSettingsFile​(java.io.File userSettings)
        Description copied from interface: InvocationRequest
        Sets the path to the user settings for the Maven invocation. Equivalent of -s and --settings
        Specified by:
        setUserSettingsFile in interface InvocationRequest
        Parameters:
        userSettings - The path to the user settings for the Maven invocation, may be null to load the user settings from the default location.
        Returns:
        This invocation request.
      • getGlobalSettingsFile

        public java.io.File getGlobalSettingsFile()
        Description copied from interface: InvocationRequest
        Gets the path to the global settings for the Maven invocation.
        Specified by:
        getGlobalSettingsFile in interface InvocationRequest
        Returns:
        The path to the global settings for the Maven invocation or null to load the global settings from the default location.
      • setGlobalSettingsFile

        public InvocationRequest setGlobalSettingsFile​(java.io.File globalSettings)
        Description copied from interface: InvocationRequest
        Sets the path to the global settings for the Maven invocation. Equivalent of -gs and --global-settings
        Specified by:
        setGlobalSettingsFile in interface InvocationRequest
        Parameters:
        globalSettings - The path to the global settings for the Maven invocation, may be null to load the global settings from the default location.
        Returns:
        This invocation request.
      • getToolchainsFile

        public java.io.File getToolchainsFile()
        Description copied from interface: InvocationRequest
        Gets the path to the custom toolchains file
        Specified by:
        getToolchainsFile in interface InvocationRequest
        Returns:
        The path to the custom toolchains file or null to load the toolchains from the default location
      • setToolchainsFile

        public InvocationRequest setToolchainsFile​(java.io.File toolchains)
        Description copied from interface: InvocationRequest
        Sets the alternate path for the user toolchains file Equivalent of -t or --toolchains

        note: available since Maven3

        Specified by:
        setToolchainsFile in interface InvocationRequest
        Parameters:
        toolchains - the alternate path for the user toolchains file
        Returns:
        This invocation request
      • getPomFileName

        public java.lang.String getPomFileName()
        Description copied from interface: InvocationRequest
        Gets the (unqualified) filename of the POM for the Maven invocation. This setting is ignored if InvocationRequest.getPomFile() does not return null. Otherwise, the base directory is assumed to contain a POM with this name. By default, a file named pom.xml is used.
        Specified by:
        getPomFileName in interface InvocationRequest
        Returns:
        The (unqualified) filename of the POM for the Maven invocation or null if not set.
      • setPomFileName

        public InvocationRequest setPomFileName​(java.lang.String pomFilename)
        Description copied from interface: InvocationRequest
        Sets the (unqualified) filename of the POM for the Maven invocation. This setting is ignored if InvocationRequest.getPomFile() does not return null. Otherwise, the base directory is assumed to contain a POM with this name.
        Specified by:
        setPomFileName in interface InvocationRequest
        Parameters:
        pomFilename - The (unqualified) filename of the POM for the Maven invocation, may be null if not used.
        Returns:
        This invocation request.
      • getProfiles

        public java.util.List<java.lang.String> getProfiles()
        Description copied from interface: InvocationRequest
        Gets the profiles for the Maven invocation.
        Specified by:
        getProfiles in interface InvocationRequest
        Returns:
        The profiles for the Maven invocation or null if not set.
      • setProfiles

        public InvocationRequest setProfiles​(java.util.List<java.lang.String> profiles)
        Description copied from interface: InvocationRequest
        Sets the profiles for the Maven invocation. Equivalent of -P and --active-profiles
        Specified by:
        setProfiles in interface InvocationRequest
        Parameters:
        profiles - The profiles for the Maven invocation, may be null to use the default profiles.
        Returns:
        This invocation request.
      • isNonPluginUpdates

        public boolean isNonPluginUpdates()
        Description copied from interface: InvocationRequest
        Indicates whether Maven should check for plugin updates. By default, plugin updates are not suppressed.
        Specified by:
        isNonPluginUpdates in interface InvocationRequest
        Returns:
        true if plugin updates should be suppressed, false otherwise.
      • setNonPluginUpdates

        public InvocationRequest setNonPluginUpdates​(boolean nonPluginUpdates)
        Description copied from interface: InvocationRequest
        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 interface InvocationRequest
        Parameters:
        nonPluginUpdates - true if plugin updates should be suppressed, false otherwise.
        Returns:
        This invocation request.
      • addShellEnvironment

        public InvocationRequest addShellEnvironment​(java.lang.String name,
                                                     java.lang.String value)
        Description copied from interface: InvocationRequest
        Adds the specified environment variable to the Maven invocation.
        Specified by:
        addShellEnvironment in interface InvocationRequest
        Parameters:
        name - The name of the environment variable, must not be null.
        value - The value of the environment variable, must not be null.
        Returns:
        This invocation request.
      • getShellEnvironments

        public java.util.Map<java.lang.String,​java.lang.String> getShellEnvironments()
        Description copied from interface: InvocationRequest
        Gets the environment variables for the Maven invocation.
        Specified by:
        getShellEnvironments in interface InvocationRequest
        Returns:
        The environment variables for the Maven invocation or null if not set.
      • getMavenOpts

        public java.lang.String getMavenOpts()
        Description copied from interface: InvocationRequest
        Gets the value of the MAVEN_OPTS environment variable.
        Specified by:
        getMavenOpts in interface InvocationRequest
        Returns:
        The value of the MAVEN_OPTS environment variable or null if not set.
      • setMavenOpts

        public InvocationRequest setMavenOpts​(java.lang.String mavenOpts)
        Description copied from interface: InvocationRequest
        Sets the value of the MAVEN_OPTS environment variable.
        Specified by:
        setMavenOpts in interface InvocationRequest
        Parameters:
        mavenOpts - The value of the MAVEN_OPTS environment variable, may be null to use the default options.
        Returns:
        This invocation request.
      • isActivatedReactor

        public boolean isActivatedReactor()
        Description copied from interface: InvocationRequest
        Gets whether Maven should search subdirectories to build a dynamic reactor
        Specified by:
        isActivatedReactor in interface InvocationRequest
        Returns:
        true if we should search subdirectories, false otherwise
      • getActivatedReactorIncludes

        public java.lang.String[] getActivatedReactorIncludes()
        Description copied from interface: InvocationRequest
        Gets the list of subdirectory patterns to search
        Specified by:
        getActivatedReactorIncludes in interface InvocationRequest
        Returns:
        list of subdirectory patterns to search, or null in which case defaults should be used
      • getActivatedReactorExcludes

        public java.lang.String[] getActivatedReactorExcludes()
        Description copied from interface: InvocationRequest
        Gets the list of subdirectory patterns to exclude from search
        Specified by:
        getActivatedReactorExcludes in interface InvocationRequest
        Returns:
        list of subdirectory patterns to exclude search, or null in which case nothing should be excluded
      • getThreads

        public java.lang.String getThreads()
        Get the value of the threads argument.
        Specified by:
        getThreads in interface InvocationRequest
        Returns:
        the value of the threads argument or null if not set
      • setThreads

        public InvocationRequest setThreads​(java.lang.String threads)
        Thread count, for instance 2.0C where C is core multiplied Equivalent of -T or --threads

        note: available since Maven3

        Specified by:
        setThreads in interface InvocationRequest
        Parameters:
        threads - the threadcount
        Returns:
        This invocation request.
      • getProjects

        public java.util.List<java.lang.String> 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 interface InvocationRequest
        Returns:
        the list of projects to add to reactor build, otherwise null
      • setProjects

        public InvocationRequest setProjects​(java.util.List<java.lang.String> projects)
        Sets the reactor project list. Equivalent of -P or --projects
        Specified by:
        setProjects in interface InvocationRequest
        Parameters:
        projects - the reactor project list
        Returns:
        This invocation request.
      • isAlsoMake

        public boolean isAlsoMake()
        Get the value of the also-make argument.
        Specified by:
        isAlsoMake in interface InvocationRequest
        Returns:
        true if the argument also-make was specified, otherwise false
      • setAlsoMake

        public InvocationRequest setAlsoMake​(boolean alsoMake)
        Enable the 'also make' mode. Equivalent of -am or --also-make
        Specified by:
        setAlsoMake in interface InvocationRequest
        Parameters:
        alsoMake - enable 'also make' mode
        Returns:
        This invocation request.
      • isAlsoMakeDependents

        public boolean isAlsoMakeDependents()
        Get the value of the also-make-dependents
        Specified by:
        isAlsoMakeDependents in interface InvocationRequest
        Returns:
        true if the argument also-make-dependents was specified, otherwise false
      • setAlsoMakeDependents

        public InvocationRequest setAlsoMakeDependents​(boolean alsoMakeDependents)
        Enable the 'also make dependents' mode. Equivalent of -amd or --also-make-dependents
        Specified by:
        setAlsoMakeDependents in interface InvocationRequest
        Parameters:
        alsoMakeDependents - enable 'also make' mode
        Returns:
        This invocation request.
      • getResumeFrom

        public java.lang.String getResumeFrom()
        Get the value of resume-from
        Specified by:
        getResumeFrom in interface InvocationRequest
        Returns:
        specified reactor project to resume from
      • setResumeFrom

        public InvocationRequest setResumeFrom​(java.lang.String resumeFrom)
        Resume reactor from specified project. Equivalent of -rf or --resume-from
        Specified by:
        setResumeFrom in interface InvocationRequest
        Parameters:
        resumeFrom - set the project to resume from
        Returns:
        This invocation request