Package org.apache.maven.api.cli
Interface Executor
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
EmbeddedMavenExecutor
,ForkedMavenExecutor
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
Modifier and TypeFieldDescriptionstatic final boolean
static final String
Maven version string returned when the actual version of Maven cannot be determined. -
Method Summary
Modifier and TypeMethodDescriptiondefault void
close()
Closes and disposes of thisExecutor
instance, releasing any resources it may hold.int
execute
(ExecutorRequest executorRequest) Invokes the tool application using the providedExecutorRequest
.mavenVersion
(ExecutorRequest executorRequest) Returns the Maven version that providedExecutorRequest
point at (would use).
-
Field Details
-
IS_WINDOWS
static final boolean IS_WINDOWS -
UNKNOWN_VERSION
Maven version string returned when the actual version of Maven cannot be determined.- See Also:
-
-
Method Details
-
execute
Invokes the tool application using the providedExecutorRequest
. 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
Returns the Maven version that providedExecutorRequest
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 beExecutorRequest.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
Closes and disposes of thisExecutor
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 interfaceAutoCloseable
- Throws:
ExecutorException
- if an error occurs while closing theExecutor
-