Skip to content

Commit 04934c6

Browse files
committed
Define a Java toolchain to remove errors
This removes a huge list of warnings that happens when using Bazel for remote build execution.
1 parent b3e40f9 commit 04934c6

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ build --java_language_version=17
33
# Ensure that Java 17-compatible bytecode is produced
44
build --java_runtime_version=remotejdk_17
55
# Force Bazel to use Java 25 for its own internal tools/helpers
6+
build --extra_toolchains=//bazel:custom_toolchain_jdk_17_definition
67
build --extra_toolchains=@rules_java//java:all
78
build --tool_java_runtime_version=remotejdk_25
89

bazel/BUILD.bazel

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
11
# This class contains common Bazel build rules used elsewhere.
2+
3+
load("@rules_java//toolchains:default_java_toolchain.bzl", "DEFAULT_TOOLCHAIN_CONFIGURATION", "default_java_toolchain")
4+
5+
default_java_toolchain(
6+
name = "custom_toolchain_jdk_17",
7+
java_runtime = "@rules_java//toolchains:remotejdk_25",
8+
jvm_opts = DEFAULT_TOOLCHAIN_CONFIGURATION["jvm_opts"] + [
9+
"-XX:+IgnoreUnrecognizedVMOptions",
10+
"--sun-misc-unsafe-memory-access=allow",
11+
],
12+
source_version = "17",
13+
target_version = "17",
14+
turbine_jvm_opts = DEFAULT_TOOLCHAIN_CONFIGURATION["turbine_jvm_opts"] + [
15+
"-XX:+IgnoreUnrecognizedVMOptions",
16+
"--sun-misc-unsafe-memory-access=allow",
17+
],
18+
visibility = ["//visibility:public"],
19+
)
20+

0 commit comments

Comments
 (0)