Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(java): explicitly define toolchains for the Java versions we support #5615

Merged
merged 2 commits into from
May 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 15 additions & 17 deletions buildenv/java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@ load("@rules_java//toolchains:default_java_toolchain.bzl", "default_java_toolcha

package(default_visibility = ["//visibility:public"])

# Bazel does not yet ship with a JDK-19 compatible JDK, so
# fetch and install our own.
default_java_toolchain(
name = "toolchain_jdk_19",
configuration = dict(),
java_runtime = "@remotejdk19_linux//:jdk",
source_version = "19",
target_version = "19",
)

default_java_toolchain(
name = "toolchain_jdk_20",
configuration = dict(),
java_runtime = "@remotejdk20_linux//:jdk",
source_version = "20",
target_version = "20",
)
# We need to have consistent JDK dependencies, which Bazel often doesn't provide out-of-the-box.
# In particular, when a target requires a particular JDK version it generally depends on
# internal class peculiar to that JDK, thus all of `source_version`, `target_version`,
# and (critically) `java_runtime` must match. Some of the upstream toolchains use a `java_runtime`
# which differs from the source and target version.
[
default_java_toolchain(
name = "toolchain_jdk_{version}".format(version = version),
configuration = dict(),
java_runtime = "@remotejdk{version}_linux//:jdk".format(version = version),
source_version = version,
target_version = version,
)
for version in ("11", "17", "19", "20")
]

config_setting(
name = "runtime_version_default",
Expand Down