Skip to content

Commit c1bcb5d

Browse files
veblushcopybara-github
authored andcommitted
[CI] Added rules_java dep to Bazel (grpc#38508)
Bazel 8 and the upcoming Protobuf v30 will need `rules_java` version 8.x. While gRPC itself doesn't directly use `rules_java`, its dependency, Envoy API, needs it and uses `rules_java` 7.x. This creates a conflict because rules_java 7.x is incompatible with both Bazel 8 and Protobuf v30. To resolve this, `rules_java` 8.x must be included in the build before Envoy API, fixing the build issue. Note that gRPC doesn't call `rules_java_toolchains`, typically found in rules_java workspace configurations ([ref](https://github.com/bazelbuild/rules_java/releases/tag/8.7.0)). This is because it can't be included in `grpc_extra_deps` where `rules_java_dependencies` is called. This is acceptable since gRPC's primary concern is Bazel build setup, not Java functionality. Partial commit of grpc#38254 Closes grpc#38508 COPYBARA_INTEGRATE_REVIEW=grpc#38508 from veblush:b8-java 10ef60c PiperOrigin-RevId: 718116320
1 parent 808f96e commit c1bcb5d

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

bazel/grpc_deps.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ def grpc_deps():
248248
],
249249
)
250250

251+
if "rules_java" not in native.existing_rules():
252+
http_archive(
253+
name = "rules_java",
254+
sha256 = "5449ed36d61269579dd9f4b0e532cd131840f285b389b3795ae8b4d717387dd8",
255+
urls = [
256+
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_java/releases/download/8.7.0/rules_java-8.7.0.tar.gz",
257+
"https://github.com/bazelbuild/rules_java/releases/download/8.7.0/rules_java-8.7.0.tar.gz",
258+
],
259+
)
260+
251261
if "io_bazel_rules_go" not in native.existing_rules():
252262
http_archive(
253263
name = "io_bazel_rules_go",

bazel/grpc_extra_deps.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
2323
load("@envoy_api//bazel:repositories.bzl", "api_dependencies")
2424
load("@google_cloud_cpp//bazel:google_cloud_cpp_deps.bzl", "google_cloud_cpp_deps")
2525
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
26+
load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
2627
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
2728
load("@rules_python//python:repositories.bzl", "py_repositories")
2829
load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")
@@ -53,6 +54,8 @@ def grpc_extra_deps(ignore_version_differences = False):
5354
rules_shell_dependencies()
5455
rules_shell_toolchains()
5556

57+
rules_java_dependencies()
58+
5659
protobuf_deps()
5760

5861
rules_proto_dependencies()

tools/run_tests/sanity/check_bazel_workspace.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"com_github_cncf_xds",
8383
"google_cloud_cpp",
8484
"rules_shell",
85+
"rules_java",
8586
]
8687

8788
_GRPC_BAZEL_ONLY_DEPS = [
@@ -111,6 +112,7 @@
111112
"com_google_libprotobuf_mutator",
112113
"google_cloud_cpp",
113114
"rules_shell",
115+
"rules_java",
114116
]
115117

116118

0 commit comments

Comments
 (0)