Interface Executor

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
EmbeddedMavenExecutor, ForkedMavenExecutor

@Experimental public interface Executor extends AutoCloseable
Defines the contract for a component responsible for executing a Maven tool using the information provided in an ExecutorRequest. This interface is central to the execution of Maven commands and builds, but it does not construct nor fully parses arguments.
Since:
4.0.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final boolean
     
    static final String
    Maven version string returned when the actual version of Maven cannot be determined.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Closes and disposes of this Executor instance, releasing any resources it may hold.
    int
    execute(ExecutorRequest executorRequest)
    Invokes the tool application using the provided ExecutorRequest.
    mavenVersion(ExecutorRequest executorRequest)
    Returns the Maven version that provided ExecutorRequest point at (would use).
  • Field Details

    • IS_WINDOWS

      static final boolean IS_WINDOWS
    • UNKNOWN_VERSION

      static final String UNKNOWN_VERSION
      Maven version string returned when the actual version of Maven cannot be determined.
      See Also:
  • Method Details

    • execute

      int execute(@Nonnull ExecutorRequest executorRequest) throws ExecutorException
      Invokes the tool application using the provided ExecutorRequest. This method is responsible for executing the command or build process based on the information contained in the request.
      Parameters:
      executorRequest - the request containing all necessary information for the execution
      Returns:
      an integer representing the exit code of the execution (0 typically indicates success)
      Throws:
      ExecutorException - if an error occurs during the execution process
    • mavenVersion

      @Nonnull String mavenVersion(@Nonnull ExecutorRequest executorRequest) throws ExecutorException
      Returns the Maven version that provided ExecutorRequest point at (would use). Please note, that this operation, depending on underlying implementation may be costly. If caller use this method often, it is caller responsibility to properly cache returned values (key can be ExecutorRequest.installationDirectory().
      Parameters:
      executorRequest - the request containing all necessary information for the execution
      Returns:
      a string representing the Maven version or UNKNOWN_VERSION
      Throws:
      ExecutorException - if an error occurs during the execution process
    • close

      default void close() throws ExecutorException
      Closes and disposes of this Executor instance, releasing any resources it may hold. This method is called automatically when using try-with-resources statements.

      The default implementation does nothing. Subclasses should override this method if they need to perform cleanup operations.

      Specified by:
      close in interface AutoCloseable
      Throws:
      ExecutorException - if an error occurs while closing the Executor