Class LookupInvoker<C extends LookupContext>

java.lang.Object
org.apache.maven.cling.invoker.LookupInvoker<C>
Type Parameters:
C - The context type.
All Implemented Interfaces:
AutoCloseable, Invoker
Direct Known Subclasses:
EncryptInvoker, MavenInvoker, ShellInvoker

public abstract class LookupInvoker<C extends LookupContext> extends Object implements Invoker
Lookup invoker implementation, that boots up DI container.
  • Field Details

  • Constructor Details

  • Method Details

    • invoke

      public final int invoke(InvokerRequest invokerRequest)
      Description copied from interface: Invoker
      Invokes the Maven application using the provided InvokerRequest. This method is responsible for executing the Maven command or build process based on the information contained in the request.
      Specified by:
      invoke in interface Invoker
      Parameters:
      invokerRequest - the request containing all necessary information for the invocation
      Returns:
      an integer representing the exit code of the invocation (0 typically indicates success)
    • doInvoke

      protected int doInvoke(C context) throws Exception
      Throws:
      Exception
    • handleException

      protected InvokerException.ExitException handleException(C context, Exception e)
    • printErrors

      protected void printErrors(C context, boolean showStackTrace, List<Logger.Entry> entries, Logger logger)
    • createContext

      protected abstract C createContext(InvokerRequest invokerRequest)
    • validate

      protected void validate(C context) throws Exception
      Throws:
      Exception
    • pushCoreProperties

      protected void pushCoreProperties(C context) throws Exception
      Throws:
      Exception
    • pushUserProperties

      protected void pushUserProperties(C context) throws Exception
      Note: this method is called twice from doInvoke(LookupContext) and modifies context. First invocation when LookupContext.pushedUserProperties is null will push user properties IF key does not already exist among Java System Properties, and collects all they key it pushes. Second invocation happens AFTER PropertyContributor SPI invocation, and "refreshes" already pushed user properties by re-writing them as SPI may have modified them.
      Throws:
      Exception
    • configureLogging

      protected void configureLogging(C context) throws Exception
      Throws:
      Exception
    • determineBuildEventListener

      protected BuildEventListener determineBuildEventListener(C context)
    • doDetermineBuildEventListener

      protected BuildEventListener doDetermineBuildEventListener(C context)
    • createTerminal

      protected final void createTerminal(C context)
    • doCreateTerminal

      protected void doCreateTerminal(C context, org.jline.terminal.TerminalBuilder builder)
      Override this method to create Terminal as you want.
      See Also:
    • doConfigureWithTerminal

      protected final void doConfigureWithTerminal(C context, org.jline.terminal.Terminal terminal)
      Called from createTerminal(LookupContext) when Terminal was built.
    • doConfigureWithTerminalWithRawStreamsEnabled

      protected void doConfigureWithTerminalWithRawStreamsEnabled(C context)
      Override this method to add some special handling for "raw streams" enabled option.
    • doConfigureWithTerminalWithRawStreamsDisabled

      protected void doConfigureWithTerminalWithRawStreamsDisabled(C context)
      Override this method to add some special handling for "raw streams" disabled option.
    • determineWriter

      protected Consumer<String> determineWriter(C context)
    • doDetermineWriter

      protected Consumer<String> doDetermineWriter(C context)
    • activateLogging

      protected void activateLogging(C context) throws Exception
      Throws:
      Exception
    • helpOrVersionAndMayExit

      protected void helpOrVersionAndMayExit(C context) throws Exception
      Throws:
      Exception
    • showVersion

      protected void showVersion(C context)
    • describe

      protected String describe(org.jline.terminal.Terminal terminal)
    • preCommands

      protected void preCommands(C context) throws Exception
      Throws:
      Exception
    • container

      protected void container(C context) throws Exception
      Throws:
      Exception
    • createContainerCapsuleFactory

      protected ContainerCapsuleFactory<C> createContainerCapsuleFactory()
    • postContainer

      protected void postContainer(C context) throws Exception
      Throws:
      Exception
    • lookup

      protected void lookup(C context) throws Exception
      Throws:
      Exception
    • init

      protected void init(C context) throws Exception
      Throws:
      Exception
    • postCommands

      protected void postCommands(C context) throws Exception
      Throws:
      Exception
    • settings

      protected void settings(C context) throws Exception
      Throws:
      Exception
    • settings

      protected Runnable settings(C context, boolean emitSettingsWarnings, SettingsBuilder settingsBuilder) throws Exception
      This method is invoked twice during "normal" LookupInvoker level startup: once when (if present) extensions are loaded up during Plexus DI creation, and once afterward as "normal" boot procedure.

      If there are Maven3 passwords presents in settings, this results in doubled warnings emitted. So Plexus DI creation call keeps "emitSettingsWarnings" false. If there are fatal issues, it will anyway "die" at that spot before warnings would be emitted.

      The method returns a "cleaner" runnable, as during extension loading the context needs to be "cleaned", restored to previous state (as it was before extension loading).

      Throws:
      Exception
    • customizeSettingsRequest

      protected void customizeSettingsRequest(C context, SettingsBuilderRequest settingsBuilderRequest) throws Exception
      Throws:
      Exception
    • customizeSettingsResult

      protected void customizeSettingsResult(C context, SettingsBuilderResult settingsBuilderResult) throws Exception
      Throws:
      Exception
    • mayDisableInteractiveMode

      protected boolean mayDisableInteractiveMode(C context, boolean proposedInteractive)
    • localRepositoryPath

      protected Path localRepositoryPath(C context)
    • populateRequest

      protected void populateRequest(C context, Lookup lookup, MavenExecutionRequest request) throws Exception
      Throws:
      Exception
    • populateRequestFromSettings

      protected void populateRequestFromSettings(MavenExecutionRequest request, Settings settings) throws Exception
      Throws:
      Exception
    • calculateDegreeOfConcurrency

      protected int calculateDegreeOfConcurrency(String threadConfiguration)
    • isRunningOnCI

      protected boolean isRunningOnCI(C context)
    • execute

      protected abstract int execute(C context) throws Exception
      Throws:
      Exception