Skip to content

Commit 30ecf3f

Browse files
comiuscopybara-github
authored andcommitted
Make rules_java backwards compatible with Bazel 6.3.0
Copybara Import from #210 BEGIN_PUBLIC Make rules_java backwards compatible with Bazel 6.3.0 (#210) Move bootstrap_toolchain_type into rules_java. There are no uses outside of rules_java. This fixes compatiblity with Bazel 6.3.0, which doesn't have the definition. Add back `_allowlist_function_transition`. Older versions of Bazel require it. Add Bazel 6.3.0 to the CI. Remove a couple of broken targets from toolchains/BUILD. Those were broken becuase old JDKs were removed. Closes #210 END_PUBLIC COPYBARA_INTEGRATE_REVIEW=#210 from comius:backward-compatible-rules_java 393f270 PiperOrigin-RevId: 670415171 Change-Id: I7f42cc92bb7285cb51a2a1185695451a644d5b30
1 parent 2392b24 commit 30ecf3f

8 files changed

+26
-22
lines changed

.bazelci/presubmit.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,19 @@ tasks:
7070
platform: windows
7171
build_flags:
7272
- "--config=bzlmod"
73-
build_targets: *build_targets_bzlmod
73+
build_targets: *build_targets_bzlmod
74+
ubuntu2004_bazel630:
75+
name: "Bazel 6.3.0"
76+
bazel: 6.3.0
77+
platform: ubuntu2004
78+
build_targets: *build_targets
79+
macos_bazel630:
80+
name: "Bazel 6.3.0"
81+
bazel: 6.3.0
82+
platform: macos
83+
build_targets: *build_targets
84+
windows_bazel630:
85+
name: "Bazel 6.3.0"
86+
bazel: 6.3.0
87+
platform: windows
88+
build_targets: *build_targets

.bazelversion

Lines changed: 0 additions & 1 deletion
This file was deleted.

MODULE.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
module(
22
name = "rules_java",
33
version = "7.9.1",
4-
# Requires @bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type.
5-
bazel_compatibility = [">=7.0.0"],
4+
bazel_compatibility = [">=6.2.0"],
65
compatibility_level = 1,
76
)
87

toolchains/BUILD

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ filegroup(
6666
#
6767
# Toolchains of this type are only consumed internally by the bootclasspath rule and should not be
6868
# accessed from Starlark.
69-
# TODO: migrate away from using @bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type ?
70-
# toolchain_type(name = "bootstrap_runtime_toolchain_type")
69+
70+
toolchain_type(name = "bootstrap_runtime_toolchain_type")
7171

7272
# Points to toolchain[":runtime_toolchain_type"] (was :legacy_current_java_runtime)
7373
java_runtime_alias(name = "current_java_runtime")
@@ -293,18 +293,6 @@ java_runtime_version_alias(
293293
visibility = ["//visibility:public"],
294294
)
295295

296-
java_runtime_version_alias(
297-
name = "remotejdk_15",
298-
runtime_version = "remotejdk_15",
299-
visibility = ["//visibility:public"],
300-
)
301-
302-
java_runtime_version_alias(
303-
name = "remotejdk_16",
304-
runtime_version = "remotejdk_16",
305-
visibility = ["//visibility:public"],
306-
)
307-
308296
java_runtime_version_alias(
309297
name = "remotejdk_17",
310298
runtime_version = "remotejdk_17",

toolchains/default_java_toolchain.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def java_runtime_files(name, srcs):
208208
tags = ["manual"],
209209
)
210210

211-
_JAVA_BOOTSTRAP_RUNTIME_TOOLCHAIN_TYPE = Label("@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type")
211+
_JAVA_BOOTSTRAP_RUNTIME_TOOLCHAIN_TYPE = Label("//toolchains:bootstrap_runtime_toolchain_type")
212212

213213
# Opt the Java bootstrap actions into path mapping:
214214
# https://github.com/bazelbuild/bazel/commit/a239ea84832f18ee8706682145e9595e71b39680

toolchains/java_toolchain_alias.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ java_runtime_version_alias = rule(
8585
toolchains = ["@bazel_tools//tools/jdk:runtime_toolchain_type"],
8686
attrs = {
8787
"runtime_version": attr.string(mandatory = True),
88+
"_allowlist_function_transition": attr.label(
89+
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
90+
),
8891
},
8992
cfg = _java_runtime_transition,
9093
)

toolchains/local_java_repository.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def local_java_runtime(name, java_home, version, runtime_name = None, visibility
110110
native.toolchain(
111111
name = "bootstrap_runtime_toolchain_definition",
112112
target_settings = [":%s_settings_alias" % name],
113-
toolchain_type = Label("@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type"),
113+
toolchain_type = Label("//toolchains:bootstrap_runtime_toolchain_type"),
114114
toolchain = runtime_name,
115115
)
116116

@@ -268,7 +268,7 @@ toolchain(
268268
toolchain(
269269
name = "bootstrap_runtime_toolchain_definition",
270270
target_settings = [":localjdk_setting"],
271-
toolchain_type = "@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type",
271+
toolchain_type = "@rules_java//tools/jdk:bootstrap_runtime_toolchain_type",
272272
toolchain = ":jdk",
273273
)
274274
'''

toolchains/remote_java_repository.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ toolchain(
8989
# the same configuration, this constraint will not result in toolchain resolution failures.
9090
exec_compatible_with = {target_compatible_with},
9191
target_settings = [":version_or_prefix_version_setting"],
92-
toolchain_type = "@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type",
92+
toolchain_type = "@rules_java//toolchains:bootstrap_runtime_toolchain_type",
9393
toolchain = "{toolchain}",
9494
)
9595
""".format(

0 commit comments

Comments
 (0)