Class InvokerProperties


  • class InvokerProperties
    extends java.lang.Object
    Provides a convenient facade around the invoker.properties.
    • Constructor Summary

      Constructors 
      Constructor Description
      InvokerProperties​(java.util.Properties properties)
      Creates a new facade for the specified invoker properties.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void configureInvocation​(org.apache.maven.shared.invoker.InvocationRequest request, int index)
      Configures the specified invocation request from these invoker properties.
      (package private) java.util.Optional<java.lang.String> get​(java.lang.String key, int index)
      Gets a value from the invoker properties.
      private java.util.Optional<java.lang.String> get​(InvokerProperties.InvocationProperty prop, int index)  
      private java.util.Map<java.lang.String,​java.lang.String> getEnvironmentVariables​(int index)
      Extract environment variable from properties for given index.
      java.lang.String getJobDescription()
      Gets the description of the corresponding build job.
      java.lang.String getJobName()
      Gets the name of the corresponding build job.
      java.lang.String getJreVersion()
      Gets the specification of JRE versions on which this build job should be run.
      java.lang.String getJreVersion​(int index)
      Gets the specification of JRE versions on which this build job should be run.
      java.lang.String getMavenVersion()
      Gets the specification of Maven versions on which this build job should be run.
      java.lang.String getMavenVersion​(int index)  
      int getOrdinal()
      Get the corresponding ordinal value
      java.lang.String getOsFamily()
      Gets the specification of OS families on which this build job should be run.
      java.lang.String getOsFamily​(int index)
      Gets the specification of OS families on which this build job should be run.
      java.util.Properties getProperties()
      Gets the invoker properties being wrapped.
      java.lang.String getSettingsFile​(int index)
      Gets the settings file used for the specified invocation.
      java.util.Collection<InvokerToolchain> getToolchains()  
      java.util.Collection<InvokerToolchain> getToolchains​(int index)  
      private java.util.Collection<InvokerToolchain> getToolchains​(java.util.regex.Pattern p)  
      java.lang.String getUserPropertiesFile​(int index)
      Gets the path to the properties file used to set the user properties for the specified invocation.
      boolean isExpectedResult​(int exitCode, int index)
      Checks whether the specified exit code matches the one expected for the given invocation.
      boolean isInvocationDefined​(int index)
      Determines whether these invoker properties contain a build definition for the specified invocation index.
      boolean isSelectorDefined​(int index)
      Determines whether these invoker properties contain a build definition for the specified selector index.
      void setDefaultDebug​(boolean defaultDebug)
      Default value for debug
      void setDefaultEnvironmentVariables​(java.util.Map<java.lang.String,​java.lang.String> defaultEnvironmentVariables)
      Default value for environmentVariables
      void setDefaultGoals​(java.util.List<java.lang.String> defaultGoals)
      Default value for goals
      void setDefaultMavenExecutable​(java.lang.String defaultMavenExecutable)
      Default value for mavenExecutable
      void setDefaultMavenOpts​(java.lang.String defaultMavenOpts)
      Default value for mavenOpts
      void setDefaultProfiles​(java.util.List<java.lang.String> defaultProfiles)
      Default value for profiles
      void setDefaultQuiet​(boolean defaultQuiet)
      Default value for quiet
      void setDefaultTimeoutInSeconds​(int defaultTimeoutInSeconds)
      Default value for timeoutInSeconds
      void setDefaultUpdateSnapshots​(boolean defaultUpdateSnapshots)
      Default value for updateSnapshots
      void setDefaultUserPropertiesFiles​(java.lang.String defaultUserPropertiesFiles)
      Default value for userPropertiesFile
      private <T> void setIfNotNull​(java.util.function.Consumer<T> consumer, T value)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        private final org.slf4j.Logger logger
      • ENVIRONMENT_VARIABLES_PATTERN

        private static final java.util.regex.Pattern ENVIRONMENT_VARIABLES_PATTERN
      • defaultDebug

        private java.lang.Boolean defaultDebug
      • defaultQuiet

        private java.lang.Boolean defaultQuiet
      • defaultGoals

        private java.util.List<java.lang.String> defaultGoals
      • defaultProfiles

        private java.util.List<java.lang.String> defaultProfiles
      • defaultMavenOpts

        private java.lang.String defaultMavenOpts
      • defaultTimeoutInSeconds

        private java.lang.Integer defaultTimeoutInSeconds
      • defaultEnvironmentVariables

        private java.util.Map<java.lang.String,​java.lang.String> defaultEnvironmentVariables
      • defaultMavenExecutable

        private java.io.File defaultMavenExecutable
      • defaultUpdateSnapshots

        private java.lang.Boolean defaultUpdateSnapshots
      • defaultUserPropertiesFiles

        private java.lang.String defaultUserPropertiesFiles
      • properties

        private final java.util.Properties properties
        The invoker properties being wrapped.
    • Constructor Detail

      • InvokerProperties

        InvokerProperties​(java.util.Properties properties)
        Creates a new facade for the specified invoker properties. The properties will not be copied, so any changes to them will be reflected by the facade.
        Parameters:
        properties - The invoker properties to wrap, may be null if none.
    • Method Detail

      • setDefaultDebug

        public void setDefaultDebug​(boolean defaultDebug)
        Default value for debug
        Parameters:
        defaultDebug - a default value
      • setDefaultQuiet

        public void setDefaultQuiet​(boolean defaultQuiet)
        Default value for quiet
        Parameters:
        defaultQuiet - a default value
      • setDefaultGoals

        public void setDefaultGoals​(java.util.List<java.lang.String> defaultGoals)
        Default value for goals
        Parameters:
        defaultGoals - a default value
      • setDefaultProfiles

        public void setDefaultProfiles​(java.util.List<java.lang.String> defaultProfiles)
        Default value for profiles
        Parameters:
        defaultProfiles - a default value
      • setDefaultMavenExecutable

        public void setDefaultMavenExecutable​(java.lang.String defaultMavenExecutable)
        Default value for mavenExecutable
        Parameters:
        defaultMavenExecutable - a default value
      • setDefaultMavenOpts

        public void setDefaultMavenOpts​(java.lang.String defaultMavenOpts)
        Default value for mavenOpts
        Parameters:
        defaultMavenOpts - a default value
      • setDefaultTimeoutInSeconds

        public void setDefaultTimeoutInSeconds​(int defaultTimeoutInSeconds)
        Default value for timeoutInSeconds
        Parameters:
        defaultTimeoutInSeconds - a default value
      • setDefaultEnvironmentVariables

        public void setDefaultEnvironmentVariables​(java.util.Map<java.lang.String,​java.lang.String> defaultEnvironmentVariables)
        Default value for environmentVariables
        Parameters:
        defaultEnvironmentVariables - a default value
      • setDefaultUpdateSnapshots

        public void setDefaultUpdateSnapshots​(boolean defaultUpdateSnapshots)
        Default value for updateSnapshots
        Parameters:
        defaultUpdateSnapshots - a default value
      • setDefaultUserPropertiesFiles

        public void setDefaultUserPropertiesFiles​(java.lang.String defaultUserPropertiesFiles)
        Default value for userPropertiesFile
        Parameters:
        defaultUserPropertiesFiles - a default value
      • getProperties

        public java.util.Properties getProperties()
        Gets the invoker properties being wrapped.
        Returns:
        The invoker properties being wrapped, never null.
      • getJobName

        public java.lang.String getJobName()
        Gets the name of the corresponding build job.
        Returns:
        The name of the build job or an empty string if not set.
      • getJobDescription

        public java.lang.String getJobDescription()
        Gets the description of the corresponding build job.
        Returns:
        The description of the build job or an empty string if not set.
      • getOrdinal

        public int getOrdinal()
        Get the corresponding ordinal value
        Returns:
        The ordinal value
      • getJreVersion

        public java.lang.String getJreVersion()
        Gets the specification of JRE versions on which this build job should be run.
        Returns:
        The specification of JRE versions or an empty string if not set.
      • getJreVersion

        public java.lang.String getJreVersion​(int index)
        Gets the specification of JRE versions on which this build job should be run.
        Returns:
        The specification of JRE versions or an empty string if not set.
      • getMavenVersion

        public java.lang.String getMavenVersion()
        Gets the specification of Maven versions on which this build job should be run.
        Returns:
        The specification of Maven versions on which this build job should be run.
        Since:
        1.5
      • getMavenVersion

        public java.lang.String getMavenVersion​(int index)
        Parameters:
        index - the selector index
        Returns:
        The specification of Maven versions on which this build job should be run.
        Since:
        3.0.0
      • getOsFamily

        public java.lang.String getOsFamily()
        Gets the specification of OS families on which this build job should be run.
        Returns:
        The specification of OS families or an empty string if not set.
      • getOsFamily

        public java.lang.String getOsFamily​(int index)
        Gets the specification of OS families on which this build job should be run.
        Parameters:
        index - the selector index
        Returns:
        The specification of OS families or an empty string if not set.
        Since:
        3.0.0
      • getToolchains

        public java.util.Collection<InvokerToolchain> getToolchains​(int index)
      • getToolchains

        private java.util.Collection<InvokerToolchain> getToolchains​(java.util.regex.Pattern p)
      • getEnvironmentVariables

        private java.util.Map<java.lang.String,​java.lang.String> getEnvironmentVariables​(int index)
        Extract environment variable from properties for given index. Every environment variable without index is also returned.
        Parameters:
        index - index to lookup
        Returns:
        map of environment name and value
      • isInvocationDefined

        public boolean isInvocationDefined​(int index)
        Determines whether these invoker properties contain a build definition for the specified invocation index.
        Parameters:
        index - The one-based index of the invocation to check for, must not be negative.
        Returns:
        true if the invocation with the specified index is defined, false otherwise.
      • isSelectorDefined

        public boolean isSelectorDefined​(int index)
        Determines whether these invoker properties contain a build definition for the specified selector index.
        Parameters:
        index - the index
        Returns:
        true if the selector with the specified index is defined, false otherwise.
        Since:
        3.0.0
      • setIfNotNull

        private <T> void setIfNotNull​(java.util.function.Consumer<T> consumer,
                                      T value)
      • configureInvocation

        public void configureInvocation​(org.apache.maven.shared.invoker.InvocationRequest request,
                                        int index)
        Configures the specified invocation request from these invoker properties. Settings not present in the invoker properties will be left unchanged in the invocation request.
        Parameters:
        request - The invocation request to configure, must not be null.
        index - The one-based index of the invocation to configure, must not be negative.
      • isExpectedResult

        public boolean isExpectedResult​(int exitCode,
                                        int index)
        Checks whether the specified exit code matches the one expected for the given invocation.
        Parameters:
        exitCode - The exit code of the Maven invocation to check.
        index - The index of the invocation for which to check the exit code, must not be negative.
        Returns:
        true if the exit code is zero and a success was expected or if the exit code is non-zero and a failue was expected, false otherwise.
      • getUserPropertiesFile

        public java.lang.String getUserPropertiesFile​(int index)
        Gets the path to the properties file used to set the user properties for the specified invocation.
        Parameters:
        index - The index of the invocation, must not be negative.
        Returns:
        The path to the properties file or null if not set.
      • getSettingsFile

        public java.lang.String getSettingsFile​(int index)
        Gets the settings file used for the specified invocation.
        Parameters:
        index - The index of the invocation, must not be negative.
        Returns:
        the value for the settings file or null if not set.
      • get

        java.util.Optional<java.lang.String> get​(java.lang.String key,
                                                 int index)
        Gets a value from the invoker properties. The invoker properties are intended to describe the invocation settings for multiple builds of the same project. For this reason, the properties are indexed. First, a property named key.index will be queried. If this property does not exist, the value of the property named key will finally be returned.
        Parameters:
        key - The (base) key for the invoker property to lookup, must not be null.
        index - The index of the invocation for which to retrieve the value, must not be negative.
        Returns:
        The value for the requested invoker property or null if not defined.