Interface ToolchainManager

All Superinterfaces:
Service

@Experimental public interface ToolchainManager extends Service
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 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 context
      type - 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 context
      type - 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 context
      type - 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 context
      toolchain - The toolchain to store
      Throws:
      ToolchainManagerException - if storing the toolchain fails