Class EmbeddedMavenExecutor
java.lang.Object
org.apache.maven.cling.executor.embedded.EmbeddedMavenExecutor
- All Implemented Interfaces:
AutoCloseable
,Executor
Embedded executor implementation, that invokes Maven from installation directory within this same JVM but in isolated
classloader. This class supports Maven 4.x and Maven 3.x as well.
The class world with Maven is kept in memory as long as instance of this class is not closed. Subsequent execution
requests over same installation home are cached.
-
Nested Class Summary
-
Field Summary
Fields inherited from interface org.apache.maven.api.cli.Executor
IS_WINDOWS, UNKNOWN_VERSION
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes and disposes of thisExecutor
instance, releasing any resources it may hold.protected URLClassLoader
createMavenBootClassLoader
(Path boot, List<URL> extraClasspath) protected void
doClose
(EmbeddedMavenExecutor.Context context) int
execute
(ExecutorRequest executorRequest) Invokes the tool application using the providedExecutorRequest
.protected String
getMavenVersion
(Class<?> clazz) mavenVersion
(ExecutorRequest executorRequest) Returns the Maven version that providedExecutorRequest
point at (would use).protected EmbeddedMavenExecutor.Context
mayCreate
(ExecutorRequest executorRequest) protected void
validate
(ExecutorRequest executorRequest)
-
Constructor Details
-
EmbeddedMavenExecutor
public EmbeddedMavenExecutor()
-
-
Method Details
-
execute
Description copied from interface:Executor
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.- Specified by:
execute
in interfaceExecutor
- 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
Description copied from interface:Executor
Returns the Maven version that providedExecutorRequest
point at (would use). Please not, 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()
.- Specified by:
mavenVersion
in interfaceExecutor
- Parameters:
executorRequest
- the request containing all necessary information for the execution- Returns:
- a string representing the Maven version or
Executor.UNKNOWN_VERSION
- Throws:
ExecutorException
- if an error occurs during the execution process
-
mayCreate
-
close
Description copied from interface:Executor
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
- Specified by:
close
in interfaceExecutor
- Throws:
ExecutorException
- if an error occurs while closing theExecutor
-
doClose
- Throws:
Exception
-
validate
- Throws:
ExecutorException
-
createMavenBootClassLoader
-
getMavenVersion
- Throws:
IOException
-