Package org.apache.maven.api.services
Interface ToolchainManager
- All Superinterfaces:
Service
- All Known Implementing Classes:
DefaultToolchainManager
,ToolchainManagerFactory.DefaultToolchainManagerV4
Service interface for managing Maven toolchains, which provide abstraction for different
build tools and environments.
A toolchain represents a specific build tool configuration (e.g., JDK, compiler) that can be used during the Maven build process. This service allows for retrieving, storing, and managing these toolchains.
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptiongetToolchainFromBuildContext
(Session session, String type) Retrieves the currently active toolchain from the build context.getToolchains
(Session session, String type) Retrieves all toolchains of the specified type without additional requirements.Retrieves toolchains matching the specified type and requirements.void
storeToolchainToBuildContext
(Session session, Toolchain toolchain) Stores a toolchain in the build context for later retrieval.
-
Method Details
-
getToolchains
@Nonnull List<Toolchain> getToolchains(@Nonnull Session session, String type, Map<String, String> requirements) Retrieves toolchains matching the specified type and requirements.- Parameters:
session
- The Maven session contexttype
- The type of toolchain (e.g., "jdk", "compiler")requirements
- Key-value pairs specifying toolchain requirements (e.g., "version": "11")- Returns:
- List of matching toolchains, never null
- Throws:
ToolchainManagerException
- if toolchain retrieval fails
-
getToolchains
@Nonnull default List<Toolchain> getToolchains(@Nonnull Session session, @Nonnull String type) throws ToolchainManagerException Retrieves all toolchains of the specified type without additional requirements.- Parameters:
session
- The Maven session contexttype
- The type of toolchain to retrieve- Returns:
- List of matching toolchains, never null
- Throws:
ToolchainManagerException
- if toolchain retrieval fails
-
getToolchainFromBuildContext
@Nonnull Optional<Toolchain> getToolchainFromBuildContext(@Nonnull Session session, @Nonnull String type) throws ToolchainManagerException Retrieves the currently active toolchain from the build context.- Parameters:
session
- The Maven session contexttype
- The type of toolchain to retrieve- Returns:
- Optional containing the toolchain if found
- Throws:
ToolchainManagerException
- if toolchain retrieval fails
-
storeToolchainToBuildContext
void storeToolchainToBuildContext(@Nonnull Session session, @Nonnull Toolchain toolchain) throws ToolchainManagerException Stores a toolchain in the build context for later retrieval.- Parameters:
session
- The Maven session contexttoolchain
- The toolchain to store- Throws:
ToolchainManagerException
- if storing the toolchain fails
-