Skip to content

Commit 20147eb

Browse files
committed
Bump rules_java to 7.12.2
Updates almost all dependencies on `@bazel_tools//tools/jdk:` toolchain targets and `.bzl` files to corresponding targets and files in `@rules_java//toolchains:`. Part of bazel-contrib#1482 and bazel-contrib#1652. All dependencies on `@bazel_tools//tools/jdk:toolchain_type` remain, however, as there is not yet a corresponding target in `@rules_java//toolchains:`. Adds the `WORKSPACE` stanza recommended in the `rules_java` release notes, and removes our own calls to instantiate `rules_java` repos and to register `rules_java` toolchains. This commit also removes `test/toolchains/jdk.bzl` or `//test/toolchains:java21_toolchain` since we no longer need them. (I actually think we didn't need them with 7.9.0, either, but this seems like a good point at which to remove them.) These changes are required to avoid build breakages when updating to `rules_scala` 7.10.0 and higher. All targets build and all tests pass under Bazel 6.5.0 and 7.4.1. --- I was on the right track in my analysis from bazel-contrib#1619 ("Bump to rules_java 7.9.0 for Bazel 7 compatibility" in the message for commit cd22d88). However, I thought we _shouldn't_ update any targets from `@bazel_tools//tools/jdk:` to `@rules_java//toolchains:`. That's why I thought we were stuck on `rules_java` 7.9.0. However, this comment from @fmeum made me think switching to `@rules_java//toolchains:` actually is the preferred approach: - bazelbuild/rules_java#214 (comment) So this is a potentially breaking change, but in the good kind of way, in that it requires an easy, future proof update.
1 parent 433bc0c commit 20147eb

File tree

18 files changed

+43
-124
lines changed

18 files changed

+43
-124
lines changed

WORKSPACE

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ load("//scala:deps.bzl", "rules_scala_dependencies")
55

66
rules_scala_dependencies()
77

8+
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
9+
10+
rules_java_dependencies()
11+
12+
rules_java_toolchains()
13+
814
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
915

1016
bazel_skylib_workspace()
@@ -109,17 +115,3 @@ rbe_preconfig(
109115
load("//scala/private/extensions:dev_deps.bzl", "dev_deps_repositories")
110116

111117
dev_deps_repositories()
112-
113-
# Copied from bazel_tools/tools/jdk/remote_java_repository.bzl.
114-
[
115-
register_toolchains(
116-
"@remotejdk21_" + platform + "_toolchain_config_repo//:all",
117-
)
118-
for platform in [
119-
"linux",
120-
"macos",
121-
"win",
122-
]
123-
]
124-
125-
register_toolchains("//test/toolchains:java21_toolchain_definition")

jmh/jmh.bzl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ scala_generate_benchmark = rule(
4444
),
4545
),
4646
"runtime_jdk": attr.label(
47-
default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
47+
default = Label("@rules_java//toolchains:current_java_runtime"),
4848
providers = [java_common.JavaRuntimeInfo],
4949
),
5050
},
@@ -65,7 +65,10 @@ def scala_benchmark_jmh(**kw):
6565
testonly = kw.get("testonly", False)
6666
scalacopts = kw.get("scalacopts", [])
6767
main_class = kw.get("main_class", "org.openjdk.jmh.Main")
68-
runtime_jdk = kw.get("runtime_jdk", "@bazel_tools//tools/jdk:current_java_runtime")
68+
runtime_jdk = kw.get(
69+
"runtime_jdk",
70+
"@rules_java//toolchains:current_java_runtime",
71+
)
6972

7073
scala_library(
7174
name = lib,

scala/deps.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def rules_scala_dependencies():
3636
http_archive,
3737
name = "rules_java",
3838
urls = [
39-
"https://github.com/bazelbuild/rules_java/releases/download/7.9.0/rules_java-7.9.0.tar.gz",
39+
"https://github.com/bazelbuild/rules_java/releases/download/7.12.2/rules_java-7.12.2.tar.gz",
4040
],
41-
sha256 = "41131de4417de70b9597e6ebd515168ed0ba843a325dc54a81b92d7af9a7b3ea",
41+
sha256 = "a9690bc00c538246880d5c83c233e4deb83fe885f54c21bb445eb8116a180b83",
4242
)
4343

4444
maybe(

scala/private/common_attributes.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ common_attrs_for_plugin_bootstrapping = {
2929
"resource_strip_prefix": attr.string(),
3030
"resource_jars": attr.label_list(allow_files = True),
3131
"java_compile_toolchain": attr.label(
32-
default = Label("@bazel_tools//tools/jdk:current_java_toolchain"),
32+
default = Label("@rules_java//toolchains:current_java_toolchain"),
3333
providers = [java_common.JavaToolchainInfo],
3434
),
3535
"scalacopts": attr.string_list(),
@@ -82,10 +82,10 @@ common_attrs.update({
8282

8383
implicit_deps = {
8484
"_java_runtime": attr.label(
85-
default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
85+
default = Label("@rules_java//toolchains:current_java_runtime"),
8686
),
8787
"_java_host_runtime": attr.label(
88-
default = Label("@bazel_tools//tools/jdk:current_host_java_runtime"),
88+
default = Label("@rules_java//toolchains:current_host_java_runtime"),
8989
),
9090
"_scalac": attr.label(
9191
executable = True,

scala/private/extensions/dev_deps.bzl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
load("//scala:scala_cross_version.bzl", "default_maven_server_urls")
44
load("//scala:scala_maven_import_external.bzl", "java_import_external")
5-
load("//test/toolchains:jdk.bzl", "remote_jdk21_repositories")
65
load("//third_party/repositories:repositories.bzl", "repositories")
76
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
8-
load("@rules_java//java:repositories.bzl", "remote_jdk8_repos")
97

108
_BUILD_TOOLS_RELEASE = "5.1.0"
119

@@ -45,10 +43,6 @@ def dev_deps_repositories(
4543
testonly_ = True,
4644
)
4745

48-
# We need to select based on platform when we use these
49-
# https://github.com/bazelbuild/bazel/issues/11655
50-
remote_jdk8_repos()
51-
5246
repositories(
5347
fetch_sources = fetch_sources,
5448
for_artifact_ids = [
@@ -73,5 +67,3 @@ def dev_deps_repositories(
7367
],
7468
maven_servers = maven_servers,
7569
)
76-
77-
remote_jdk21_repositories()

scala/private/rule_impls.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"""Rules for supporting the Scala language."""
1515

1616
load("@bazel_skylib//lib:paths.bzl", "paths")
17-
load("@bazel_tools//tools/jdk:toolchain_utils.bzl", "find_java_toolchain")
17+
load("@rules_java//toolchains:toolchain_utils.bzl", "find_java_toolchain")
1818
load(":common.bzl", "rlocationpath_from_rootpath", _collect_plugin_paths = "collect_plugin_paths")
1919
load(":resources.bzl", _resource_paths = "paths")
2020

scala/private/rules/scala_binary.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ _scala_binary_attrs = {
5858
"classpath_resources": attr.label_list(allow_files = True),
5959
"jvm_flags": attr.string_list(),
6060
"runtime_jdk": attr.label(
61-
default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
61+
default = Label("@rules_java//toolchains:current_java_runtime"),
6262
providers = [java_common.JavaRuntimeInfo],
6363
),
6464
}

scala/private/rules/scala_junit_test.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ _scala_junit_test_attrs = {
7979
),
8080
"jvm_flags": attr.string_list(),
8181
"runtime_jdk": attr.label(
82-
default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
82+
default = Label("@rules_java//toolchains:current_java_runtime"),
8383
providers = [java_common.JavaRuntimeInfo],
8484
),
8585
"env": attr.string_dict(default = {}),

scala/scala_import.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ scala_import = rule(
145145
default = Label("//scala/settings:stamp_scala_import"),
146146
),
147147
"java_compile_toolchain": attr.label(
148-
default = Label("@bazel_tools//tools/jdk:current_java_toolchain"),
148+
default = Label("@rules_java//toolchains:current_java_toolchain"),
149149
),
150150
},
151151
toolchains = ["@bazel_tools//tools/jdk:toolchain_type"],

scala/scalafmt/phase_scalafmt_ext.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ ext_scalafmt = {
2424
executable = True,
2525
),
2626
"_java_host_runtime": attr.label(
27-
default = Label("@bazel_tools//tools/jdk:current_host_java_runtime"),
27+
default = Label(
28+
"@rules_java//toolchains:current_host_java_runtime",
29+
),
2830
),
2931
"_runner": attr.label(
3032
allow_single_file = True,

0 commit comments

Comments
 (0)