-
Notifications
You must be signed in to change notification settings - Fork 97
Description
Feature request: Make liberty-maven-plugin toolchain-aware
Context
When using the maven-toolchains-plugin,
Maven selects a specific JDK based on the configured toolchains and stores it in the build context
(via ToolchainManagerPrivate.storeToolchainToBuildContext).
Other plugins (like maven-compiler-plugin, maven-surefire-plugin, etc.) can then retrieve the
active toolchain with ToolchainManager.getToolchainFromBuildContext(...) and use the JDK selected
by the user, instead of relying on the JDK that runs Maven itself.
Current behavior
The Liberty Maven Plugin currently ignores toolchains.
It by default uses the JDK from the environment that runs Maven, even when a specific toolchain is configured.
Possibly workaround is by means of env.JAVA_HOME, but that duplicates what toolchain plugin is for.
Expected behavior
The plugin should honor the active toolchain and use the JDK selected by Maven Toolchains.
This would allow consistent builds when multiple JDKs are installed and toolchains are configured
(e.g., building a Liberty app on Java 8 even if Maven is running on Java 17).
Proposed implementation
The plugin could retrieve the configured toolchain early during execution, for example:
@Component
private ToolchainManager toolchainManager;
@Component
private MavenSession session;
public void execute() throws MojoExecutionException {
Toolchain tc = toolchainManager.getToolchainFromBuildContext("jdk", session);
if (tc != null) { [...] }
}