Define a Java toolchain to remove errors This removes a huge list of warnings that happens when using Bazel for remote build execution.
diff --git a/.bazelrc b/.bazelrc index 1026f44..e1027d2 100644 --- a/.bazelrc +++ b/.bazelrc
@@ -3,6 +3,7 @@ # Ensure that Java 17-compatible bytecode is produced build --java_runtime_version=remotejdk_17 # Force Bazel to use Java 25 for its own internal tools/helpers +build --extra_toolchains=//bazel:custom_toolchain_jdk_17_definition build --extra_toolchains=@rules_java//java:all build --tool_java_runtime_version=remotejdk_25
diff --git a/bazel/BUILD.bazel b/bazel/BUILD.bazel index edeb91d..94a889e 100644 --- a/bazel/BUILD.bazel +++ b/bazel/BUILD.bazel
@@ -1 +1,20 @@ # This class contains common Bazel build rules used elsewhere. + +load("@rules_java//toolchains:default_java_toolchain.bzl", "DEFAULT_TOOLCHAIN_CONFIGURATION", "default_java_toolchain") + +default_java_toolchain( + name = "custom_toolchain_jdk_17", + java_runtime = "@rules_java//toolchains:remotejdk_25", + jvm_opts = DEFAULT_TOOLCHAIN_CONFIGURATION["jvm_opts"] + [ + "-XX:+IgnoreUnrecognizedVMOptions", + "--sun-misc-unsafe-memory-access=allow", + ], + source_version = "17", + target_version = "17", + turbine_jvm_opts = DEFAULT_TOOLCHAIN_CONFIGURATION["turbine_jvm_opts"] + [ + "-XX:+IgnoreUnrecognizedVMOptions", + "--sun-misc-unsafe-memory-access=allow", + ], + visibility = ["//visibility:public"], +) +