Skip to content

Commit

Permalink
Add toolchain java path to environment variables in ExecMojo
Browse files Browse the repository at this point in the history
  • Loading branch information
mmazur authored and slawekjaranowski committed Oct 21, 2024
1 parent e54e602 commit 16cd225
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/codehaus/mojo/exec/ExecMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/**
* <p>
Expand Down Expand Up @@ -488,6 +489,11 @@ private Map<String, String> handleSystemEnvVariables() throws MojoExecutionExcep
}
}

Toolchain tc = getToolchain();
if (tc != null) {
enviro.put(TOOLCHAIN_JAVA_ENV_NAME, tc.findTool("java"));
}

if (this.getLog().isDebugEnabled()) {
Set<String> keys = new TreeSet<>(enviro.keySet());
for (String key : keys) {
Expand Down

0 comments on commit 16cd225

Please sign in to comment.