Skip to content

Make rules_java backwards compatible with Bazel 6.3.0 #210

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,19 @@ tasks:
platform: windows
build_flags:
- "--config=bzlmod"
build_targets: *build_targets_bzlmod
build_targets: *build_targets_bzlmod
ubuntu2004_bazel630:
name: "Bazel 6.3.0"
bazel: 6.3.0
platform: ubuntu2004
build_targets: *build_targets
macos_bazel630:
name: "Bazel 6.3.0"
bazel: 6.3.0
platform: macos
build_targets: *build_targets
windows_bazel630:
name: "Bazel 6.3.0"
bazel: 6.3.0
platform: windows
build_targets: *build_targets
1 change: 0 additions & 1 deletion .bazelversion

This file was deleted.

3 changes: 1 addition & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module(
name = "rules_java",
version = "7.9.1",
# Requires @bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type.
bazel_compatibility = [">=7.0.0"],
bazel_compatibility = [">=6.2.0"],
compatibility_level = 1,
)

Expand Down
16 changes: 2 additions & 14 deletions toolchains/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ filegroup(
#
# Toolchains of this type are only consumed internally by the bootclasspath rule and should not be
# accessed from Starlark.
# TODO: migrate away from using @bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type ?
# toolchain_type(name = "bootstrap_runtime_toolchain_type")

toolchain_type(name = "bootstrap_runtime_toolchain_type")

# Points to toolchain[":runtime_toolchain_type"] (was :legacy_current_java_runtime)
java_runtime_alias(name = "current_java_runtime")
Expand Down Expand Up @@ -293,18 +293,6 @@ java_runtime_version_alias(
visibility = ["//visibility:public"],
)

java_runtime_version_alias(
name = "remotejdk_15",
runtime_version = "remotejdk_15",
visibility = ["//visibility:public"],
)

java_runtime_version_alias(
name = "remotejdk_16",
runtime_version = "remotejdk_16",
visibility = ["//visibility:public"],
)

java_runtime_version_alias(
name = "remotejdk_17",
runtime_version = "remotejdk_17",
Expand Down
2 changes: 1 addition & 1 deletion toolchains/default_java_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def java_runtime_files(name, srcs):
tags = ["manual"],
)

_JAVA_BOOTSTRAP_RUNTIME_TOOLCHAIN_TYPE = Label("@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type")
_JAVA_BOOTSTRAP_RUNTIME_TOOLCHAIN_TYPE = Label("//toolchains:bootstrap_runtime_toolchain_type")

# Opt the Java bootstrap actions into path mapping:
# https://github.com/bazelbuild/bazel/commit/a239ea84832f18ee8706682145e9595e71b39680
Expand Down
3 changes: 3 additions & 0 deletions toolchains/java_toolchain_alias.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ java_runtime_version_alias = rule(
toolchains = ["@bazel_tools//tools/jdk:runtime_toolchain_type"],
attrs = {
"runtime_version": attr.string(mandatory = True),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
cfg = _java_runtime_transition,
)
Expand Down
4 changes: 2 additions & 2 deletions toolchains/local_java_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def local_java_runtime(name, java_home, version, runtime_name = None, visibility
native.toolchain(
name = "bootstrap_runtime_toolchain_definition",
target_settings = [":%s_settings_alias" % name],
toolchain_type = Label("@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type"),
toolchain_type = Label("//toolchains:bootstrap_runtime_toolchain_type"),
toolchain = runtime_name,
)

Expand Down Expand Up @@ -268,7 +268,7 @@ toolchain(
toolchain(
name = "bootstrap_runtime_toolchain_definition",
target_settings = [":localjdk_setting"],
toolchain_type = "@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type",
toolchain_type = "@rules_java//tools/jdk:bootstrap_runtime_toolchain_type",
toolchain = ":jdk",
)
'''
Expand Down
2 changes: 1 addition & 1 deletion toolchains/remote_java_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ toolchain(
# the same configuration, this constraint will not result in toolchain resolution failures.
exec_compatible_with = {target_compatible_with},
target_settings = [":version_or_prefix_version_setting"],
toolchain_type = "@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type",
toolchain_type = "@rules_java//toolchains:bootstrap_runtime_toolchain_type",
toolchain = "{toolchain}",
)
""".format(
Expand Down