Skip to content

Commit 042e9a6

Browse files
Wyveraldrules_java Copybara
authored andcommitted
Use @platforms//host instead of @local_config_platform
The latter is deprecated (currently aliases to the former) and will be removed in Bazel 9. See similar unknown commit for rules_cc. PiperOrigin-RevId: 761901757 Change-Id: I133adb35ebb5f388ca02e61409267820db804763
1 parent 4ce6ca9 commit 042e9a6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

toolchains/local_java_repository.bzl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,18 @@ local_java_runtime(
235235
)
236236
""" % (local_java_runtime_name, runtime_name, java_home, version)
237237

238+
bazel = native.bazel_version
239+
if not bazel or bazel >= "7":
240+
# Bazel 7+ uses @platforms//host for the host platform.
241+
load_host_constraints = 'load("@platforms//host:constraints.bzl", "HOST_CONSTRAINTS")\n'
242+
else:
243+
# Bazel 6 uses @local_config_platform instead, but it's being removed in Bazel 9.
244+
load_host_constraints = 'load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS")\n'
245+
238246
repository_ctx.file(
239247
"BUILD.bazel",
240248
'load("@rules_java//toolchains:local_java_repository.bzl", "local_java_runtime")\n' +
241-
'load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS")\n' +
249+
load_host_constraints +
242250
build_file +
243251
local_java_runtime_macro,
244252
)

0 commit comments

Comments
 (0)