From 11e73beb2924b5915b031f6cd53b7de7890be89d Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Fri, 22 Sep 2023 08:15:34 +0200 Subject: [PATCH] Set `java` on remote JDKs If the `java` attribute on `java_runtime` isn't set, Bazel guesses it based on the host platform, which can be different from the execution platform. https://github.com/bazelbuild/bazel/blob/04a05677e4714434ec196c45a4ccbd8e0ef2f0ff/src/main/java/com/google/devtools/build/lib/rules/java/JavaRuntime.java#L46 Work towards https://github.com/bazelbuild/bazel/issues/19587 --- toolchains/jdk_build_file.bzl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/toolchains/jdk_build_file.bzl b/toolchains/jdk_build_file.bzl index 71b615aa..466c6dca 100644 --- a/toolchains/jdk_build_file.bzl +++ b/toolchains/jdk_build_file.bzl @@ -83,6 +83,9 @@ java_runtime( ":jdk-lib", ":jre", ], + # Provide the 'java` binary explicitly so that the correct path is used by + # Bazel even when the host platform differs from the execution platform. + java = glob(["bin/java.exe", "bin/java"])[0], version = {RUNTIME_VERSION}, ) """