Class MavenCli

java.lang.Object
org.apache.maven.cli.MavenCli

public class MavenCli extends Object
  • Field Details

    • LOCAL_REPO_PROPERTY

      public static final String LOCAL_REPO_PROPERTY
      See Also:
    • MULTIMODULE_PROJECT_DIRECTORY

      public static final String MULTIMODULE_PROJECT_DIRECTORY
      See Also:
    • USER_HOME

      public static final String USER_HOME
    • USER_MAVEN_CONFIGURATION_HOME

      public static final File USER_MAVEN_CONFIGURATION_HOME
    • DEFAULT_USER_TOOLCHAINS_FILE

      public static final File DEFAULT_USER_TOOLCHAINS_FILE
    • DEFAULT_GLOBAL_TOOLCHAINS_FILE

      public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE
    • EXT_CLASS_PATH

      private static final String EXT_CLASS_PATH
      See Also:
    • DOT_MVN

      private static final String DOT_MVN
      See Also:
    • UNABLE_TO_FIND_ROOT_PROJECT_MESSAGE

      private static final String UNABLE_TO_FIND_ROOT_PROJECT_MESSAGE
      See Also:
    • EXTENSIONS_FILENAME

      private static final String EXTENSIONS_FILENAME
      See Also:
    • MVN_MAVEN_CONFIG

      private static final String MVN_MAVEN_CONFIG
      See Also:
    • STYLE_COLOR_PROPERTY

      public static final String STYLE_COLOR_PROPERTY
      See Also:
    • 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
    • eventSpyDispatcher

      private EventSpyDispatcher eventSpyDispatcher
    • modelProcessor

      private ModelProcessor modelProcessor
    • maven

      private Maven maven
    • executionRequestPopulator

      private MavenExecutionRequestPopulator executionRequestPopulator
    • toolchainsBuilder

      private ToolchainsBuilder toolchainsBuilder
    • dispatcher

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

      private Map<String,ConfigurationProcessor> configurationProcessors
    • cliManager

      private CLIManager cliManager
    • NEXT_LINE

      private static final Pattern NEXT_LINE
    • LAST_ANSI_SEQUENCE

      private static final Pattern LAST_ANSI_SEQUENCE
    • ANSI_RESET

      private static final String ANSI_RESET
      See Also:
  • Constructor Details

    • MavenCli

      public MavenCli()
    • MavenCli

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

    • main

      public static void main(String[] args)
    • main

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

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

      public int doMain(String[] args, String workingDirectory, PrintStream stdout, 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)
    • initialize

      void initialize(CliRequest cliRequest) throws MavenCli.ExitException
      Throws:
      MavenCli.ExitException
    • cli

      void cli(CliRequest cliRequest) throws Exception
      Throws:
      Exception
    • informativeCommands

      private void informativeCommands(CliRequest cliRequest) throws MavenCli.ExitException
      Throws:
      MavenCli.ExitException
    • 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)
    • properties

      void properties(CliRequest cliRequest) throws MavenCli.ExitException
      Throws:
      MavenCli.ExitException
    • container

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

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

      private List<CoreExtension> readCoreExtensionsDescriptor(File extensionsFile) throws IOException, org.codehaus.plexus.util.xml.pull.XmlPullParserException
      Throws:
      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, List<File> extClassPath, List<CoreExtensionEntry> extensions) throws Exception
      Throws:
      Exception
    • reverse

      private static <T> List<T> reverse(List<T> list)
    • parseExtClasspath

      private List<File> parseExtClasspath(CliRequest cliRequest)
    • encryption

      private void encryption(CliRequest cliRequest) throws Exception
      Throws:
      Exception
    • execute

      private int execute(CliRequest cliRequest) throws MavenExecutionRequestPopulationException
      Throws:
      MavenExecutionRequestPopulationException
    • getResumeFrom

      private String getResumeFrom(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, Map<String,String> references, String indent, boolean showErrors)
    • configure

      private void configure(CliRequest cliRequest) throws Exception
      Throws:
      Exception
    • toolchains

      void toolchains(CliRequest cliRequest) throws Exception
      Throws:
      Exception
    • getLocation

      private Object getLocation(Source source, File defaultLocation)
    • populateRequest

      private MavenExecutionRequest populateRequest(CliRequest cliRequest)
    • populateRequest

      private MavenExecutionRequest populateRequest(CliRequest cliRequest, MavenExecutionRequest request)
    • calculateDegreeOfConcurrency

      int calculateDegreeOfConcurrency(String threadConfiguration)
    • populateProperties

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

      protected boolean isAcceptableRootDirectory(Path path)
    • searchAcceptableRootDirectory

      protected Path searchAcceptableRootDirectory(Path path)
    • createInterpolator

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

      private static Path getCanonicalPath(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