diff --git a/src/main/java/org/codehaus/mojo/exec/ExecMojo.java b/src/main/java/org/codehaus/mojo/exec/ExecMojo.java index 740fb301..52e9999a 100644 --- a/src/main/java/org/codehaus/mojo/exec/ExecMojo.java +++ b/src/main/java/org/codehaus/mojo/exec/ExecMojo.java @@ -87,6 +87,7 @@ public class ExecMojo extends AbstractExecMojo { * Trying to recognize whether the given {@link #executable} might be a {@code java} binary. */ private static final Pattern ENDS_WITH_JAVA = Pattern.compile("^.*java(\\.exe|\\.bin)?$", Pattern.CASE_INSENSITIVE); + private static final String TOOLCHAIN_JAVA_ENV_NAME = "TOOLCHAIN_JAVA"; /** *

@@ -488,6 +489,11 @@ private Map handleSystemEnvVariables() throws MojoExecutionExcep } } + Toolchain tc = getToolchain(); + if (tc != null) { + enviro.put(TOOLCHAIN_JAVA_ENV_NAME, tc.findTool("java")); + } + if (this.getLog().isDebugEnabled()) { Set keys = new TreeSet<>(enviro.keySet()); for (String key : keys) {