Class MavenInvoker

java.lang.Object
org.apache.maven.cling.invoker.LookupInvoker<MavenContext>
org.apache.maven.cling.invoker.mvn.MavenInvoker
All Implemented Interfaces:
AutoCloseable, org.apache.maven.api.cli.Invoker
Direct Known Subclasses:
ResidentMavenInvoker

public class MavenInvoker extends LookupInvoker<MavenContext>
The Maven invoker, that expects whole Maven on classpath and invokes it.
  • Field Details

    • NEXT_LINE

      protected static final Pattern NEXT_LINE
    • LAST_ANSI_SEQUENCE

      protected static final Pattern LAST_ANSI_SEQUENCE
    • ANSI_RESET

      protected static final String ANSI_RESET
      See Also:
  • Constructor Details

    • MavenInvoker

      public MavenInvoker(org.apache.maven.api.services.Lookup protoLookup, @Nullable Consumer<LookupContext> contextConsumer)
  • Method Details

    • createContext

      protected MavenContext createContext(org.apache.maven.api.cli.InvokerRequest invokerRequest)
      Specified by:
      createContext in class LookupInvoker<MavenContext>
    • execute

      protected int execute(MavenContext context) throws Exception
      Specified by:
      execute in class LookupInvoker<MavenContext>
      Throws:
      Exception
    • prepareMavenExecutionRequest

      protected org.apache.maven.execution.MavenExecutionRequest prepareMavenExecutionRequest() throws Exception
      Throws:
      Exception
    • lookup

      protected void lookup(MavenContext context) throws Exception
      Overrides:
      lookup in class LookupInvoker<MavenContext>
      Throws:
      Exception
    • postCommands

      protected void postCommands(MavenContext context) throws Exception
      Overrides:
      postCommands in class LookupInvoker<MavenContext>
      Throws:
      Exception
    • toolchains

      protected void toolchains(MavenContext context, org.apache.maven.execution.MavenExecutionRequest request) throws Exception
      Throws:
      Exception
    • populateRequest

      protected void populateRequest(MavenContext context, org.apache.maven.api.services.Lookup lookup, org.apache.maven.execution.MavenExecutionRequest request) throws Exception
      Overrides:
      populateRequest in class LookupInvoker<MavenContext>
      Throws:
      Exception
    • determinePom

      protected Path determinePom(MavenContext context, org.apache.maven.api.services.Lookup lookup)
    • determineReactorFailureBehaviour

      protected String determineReactorFailureBehaviour(MavenContext context)
    • determineGlobalChecksumPolicy

      protected String determineGlobalChecksumPolicy(MavenContext context)
    • determineExecutionListener

      protected org.apache.maven.execution.ExecutionListener determineExecutionListener(MavenContext context)
    • determineTransferListener

      protected org.eclipse.aether.transfer.TransferListener determineTransferListener(MavenContext context, boolean noTransferProgress)
    • determineMakeBehavior

      protected String determineMakeBehavior(MavenContext context)
    • performProjectActivation

      protected void performProjectActivation(MavenContext context, org.apache.maven.execution.ProjectActivation projectActivation)
    • performProfileActivation

      protected void performProfileActivation(MavenContext context, org.apache.maven.execution.ProfileActivation profileActivation)
    • doExecute

      protected int doExecute(MavenContext context, org.apache.maven.execution.MavenExecutionRequest request) throws Exception
      Throws:
      Exception
    • logBuildResumeHint

      protected void logBuildResumeHint(MavenContext context, String resumeBuildHint)
    • getResumeFromSelector

      protected String getResumeFromSelector(List<org.apache.maven.project.MavenProject> mavenProjects, org.apache.maven.project.MavenProject firstFailedProject)
      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. This method is made package-private for testing purposes.

      Parameters:
      mavenProjects - Maven projects which are part of build execution.
      firstFailedProject - The first 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

      protected void logSummary(MavenContext context, org.apache.maven.exception.ExceptionSummary summary, Map<String,String> references, String indent)