Class MavenCli


  • public class MavenCli
    extends java.lang.Object
    • Field Detail

      • LOCAL_REPO_PROPERTY

        public static final java.lang.String LOCAL_REPO_PROPERTY
        See Also:
        Constant Field Values
      • MULTIMODULE_PROJECT_DIRECTORY

        public static final java.lang.String MULTIMODULE_PROJECT_DIRECTORY
        See Also:
        Constant Field Values
      • USER_HOME

        public static final java.lang.String USER_HOME
      • USER_MAVEN_CONFIGURATION_HOME

        public static final java.io.File USER_MAVEN_CONFIGURATION_HOME
      • DEFAULT_USER_TOOLCHAINS_FILE

        public static final java.io.File DEFAULT_USER_TOOLCHAINS_FILE
      • DEFAULT_GLOBAL_TOOLCHAINS_FILE

        public static final java.io.File DEFAULT_GLOBAL_TOOLCHAINS_FILE
      • UNABLE_TO_FIND_ROOT_PROJECT_MESSAGE

        private static final java.lang.String UNABLE_TO_FIND_ROOT_PROJECT_MESSAGE
        See Also:
        Constant Field Values
      • EXTENSIONS_FILENAME

        private static final java.lang.String EXTENSIONS_FILENAME
        See Also:
        Constant Field Values
      • MVN_MAVEN_CONFIG

        private static final java.lang.String MVN_MAVEN_CONFIG
        See Also:
        Constant Field Values
      • STYLE_COLOR_PROPERTY

        public static final java.lang.String STYLE_COLOR_PROPERTY
        See Also:
        Constant Field Values
      • classWorld

        private org.codehaus.plexus.classworlds.ClassWorld classWorld
      • plexusLoggerManager

        private org.codehaus.plexus.logging.LoggerManager plexusLoggerManager
      • slf4jLoggerFactory

        private org.slf4j.ILoggerFactory slf4jLoggerFactory
      • slf4jLogger

        private org.slf4j.Logger slf4jLogger
      • maven

        private Maven maven
      • dispatcher

        private org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher dispatcher
      • configurationProcessors

        private java.util.Map<java.lang.String,​ConfigurationProcessor> configurationProcessors
      • NEXT_LINE

        private static final java.util.regex.Pattern NEXT_LINE
      • LAST_ANSI_SEQUENCE

        private static final java.util.regex.Pattern LAST_ANSI_SEQUENCE
    • Constructor Detail

      • MavenCli

        public MavenCli()
      • MavenCli

        public MavenCli​(org.codehaus.plexus.classworlds.ClassWorld classWorld)
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
      • main

        public static int main​(java.lang.String[] args,
                               org.codehaus.plexus.classworlds.ClassWorld classWorld)
      • doMain

        public static int doMain​(java.lang.String[] args,
                                 org.codehaus.plexus.classworlds.ClassWorld classWorld)
      • doMain

        public int doMain​(java.lang.String[] args,
                          java.lang.String workingDirectory,
                          java.io.PrintStream stdout,
                          java.io.PrintStream stderr)
        This supports painless invocation by the Verifier during embedded execution of the core ITs. See Embedded3xLauncher in maven-verifier
      • doMain

        public int doMain​(CliRequest cliRequest)
      • cli

        void cli​(CliRequest cliRequest)
          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • cliMerge

        private org.apache.commons.cli.CommandLine cliMerge​(org.apache.commons.cli.CommandLine mavenConfig,
                                                            org.apache.commons.cli.CommandLine mavenCli)
      • logging

        void logging​(CliRequest cliRequest)
        configure logging
      • version

        private void version​(CliRequest cliRequest)
      • commands

        private void commands​(CliRequest cliRequest)
      • container

        org.codehaus.plexus.PlexusContainer container​(CliRequest cliRequest)
                                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • loadCoreExtensions

        private java.util.List<CoreExtensionEntry> loadCoreExtensions​(CliRequest cliRequest,
                                                                      org.codehaus.plexus.classworlds.realm.ClassRealm containerRealm,
                                                                      java.util.Set<java.lang.String> providedArtifacts)
                                                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • readCoreExtensionsDescriptor

        private java.util.List<CoreExtension> readCoreExtensionsDescriptor​(java.io.File extensionsFile)
                                                                    throws java.io.IOException,
                                                                           org.codehaus.plexus.util.xml.pull.XmlPullParserException
        Throws:
        java.io.IOException
        org.codehaus.plexus.util.xml.pull.XmlPullParserException
      • setupContainerRealm

        private org.codehaus.plexus.classworlds.realm.ClassRealm setupContainerRealm​(org.codehaus.plexus.classworlds.ClassWorld classWorld,
                                                                                     org.codehaus.plexus.classworlds.realm.ClassRealm coreRealm,
                                                                                     java.util.List<java.io.File> extClassPath,
                                                                                     java.util.List<CoreExtensionEntry> extensions)
                                                                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • reverse

        private static <T> java.util.List<T> reverse​(java.util.List<T> list)
      • parseExtClasspath

        private java.util.List<java.io.File> parseExtClasspath​(CliRequest cliRequest)
      • encryption

        private void encryption​(CliRequest cliRequest)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getResumeFrom

        private java.lang.String getResumeFrom​(java.util.List<MavenProject> mavenProjects,
                                               MavenProject failedProject)
        A helper method to determine the value to resume the build with -rf taking into account the edge case where multiple modules in the reactor have the same artifactId.

        -rf :artifactId will pick up the first module which matches, but when multiple modules in the reactor have the same artifactId, effective failed module might be later in build reactor. This means that developer will either have to type groupId or wait for build execution of all modules which were fine, but they are still before one which reported errors.

        Then the returned value is groupId:artifactId when there is a name clash and :artifactId if there is no conflict.

        Parameters:
        mavenProjects - Maven projects which are part of build execution.
        failedProject - Project which has failed.
        Returns:
        Value for -rf flag to resume build exactly from place where it failed (:artifactId in general and groupId:artifactId when there is a name clash).
      • logSummary

        private void logSummary​(ExceptionSummary summary,
                                java.util.Map<java.lang.String,​java.lang.String> references,
                                java.lang.String indent,
                                boolean showErrors)
      • configure

        private void configure​(CliRequest cliRequest)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • toolchains

        void toolchains​(CliRequest cliRequest)
                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getLocation

        private java.lang.Object getLocation​(Source source,
                                             java.io.File defaultLocation)
      • calculateDegreeOfConcurrency

        int calculateDegreeOfConcurrency​(java.lang.String threadConfiguration)
      • populateProperties

        static void populateProperties​(CliRequest cliRequest,
                                       java.util.Properties systemProperties,
                                       java.util.Properties userProperties)
                                throws org.codehaus.plexus.interpolation.InterpolationException
        Throws:
        org.codehaus.plexus.interpolation.InterpolationException
      • isAcceptableRootDirectory

        protected boolean isAcceptableRootDirectory​(java.nio.file.Path path)
      • searchAcceptableRootDirectory

        protected java.nio.file.Path searchAcceptableRootDirectory​(java.nio.file.Path path)
      • createInterpolator

        protected static org.codehaus.plexus.interpolation.StringSearchInterpolator createInterpolator​(CliRequest cliRequest,
                                                                                                       java.util.Properties... properties)
      • getCanonicalPath

        private static java.nio.file.Path getCanonicalPath​(java.nio.file.Path path)
      • getConsoleTransferListener

        protected org.eclipse.aether.transfer.TransferListener getConsoleTransferListener​(boolean printResourceNames)
      • getBatchTransferListener

        protected org.eclipse.aether.transfer.TransferListener getBatchTransferListener()
      • customizeContainer

        protected void customizeContainer​(org.codehaus.plexus.PlexusContainer container)
      • createModelProcessor

        protected ModelProcessor createModelProcessor​(org.codehaus.plexus.PlexusContainer container)
                                               throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
        Throws:
        org.codehaus.plexus.component.repository.exception.ComponentLookupException