Skip to content

Commit b032e6d

Browse files
authored
Replace the grpc-java bazel dep with an http_archive (bazel-contrib#364)
The `bazel_dep` of `grpc-java` pollutes the default `maven` namespace, and also overrides part of protobuf. That seems a little excessive for something we use once. Instead, we now download the `http_archive` directly and patch it.
1 parent 639446e commit b032e6d

File tree

5 files changed

+226
-475
lines changed

5 files changed

+226
-475
lines changed

MODULE.bazel

Lines changed: 17 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ module(
44
repo_name = "contrib_rules_jvm",
55
)
66

7-
# TODO: This should be read from repositories.bzl, but we can't until this issue is solved:
8-
# - https://github.com/bazelbuild/bazel/issues/17880
97
PROTOBUF_VERSION = "21.7"
108

119
# The java packages are published to maven under a different versioning scheme.
1210
PROTOBUF_JAVA_VERSION = "3.{}".format(PROTOBUF_VERSION)
1311

1412
bazel_dep(name = "apple_rules_lint", version = "0.4.0")
1513
bazel_dep(name = "bazel_skylib", version = "1.8.1")
16-
bazel_dep(name = "grpc-java", version = "1.71.0")
1714
bazel_dep(name = "gazelle", version = "0.42.0", repo_name = "bazel_gazelle")
1815
bazel_dep(name = "protobuf", version = "29.1", repo_name = "com_google_protobuf")
1916
bazel_dep(name = "rules_cc", version = "0.1.1")
@@ -49,41 +46,27 @@ use_repo(
4946
"apple_linters",
5047
)
5148

49+
# There is a `grpc_java` bazel_dep we could use, but that pollutes the main
50+
# `maven` namespace and patches `protobuf` too. Instead, we pull the http
51+
# archive and patch it so we can use it in the one target we care about
52+
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
53+
54+
http_archive(
55+
name = "grpc-java",
56+
integrity = "sha256-KUKla3lEeaC8HA5pA5ya5hXxyznQ468SrzXA6zvXP98=",
57+
patch_args = ["-p1"],
58+
patches = [
59+
"//third_party:grpc-java.patch",
60+
],
61+
strip_prefix = "grpc-java-1.71.0",
62+
url = "https://github.com/grpc/grpc-java/archive/refs/tags/v1.71.0.tar.gz",
63+
)
64+
5265
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
5366

5467
IO_GRPC_GRPC_JAVA_ARTIFACTS = [
55-
"com.google.android:annotations:4.1.1.4",
5668
"com.google.api.grpc:proto-google-common-protos:2.9.0",
57-
"com.google.auth:google-auth-library-credentials:0.22.0",
58-
"com.google.auth:google-auth-library-oauth2-http:0.22.0",
59-
"com.google.auto.value:auto-value-annotations:1.9",
60-
"com.google.auto.value:auto-value:1.9",
61-
"com.google.code.findbugs:jsr305:3.0.2",
62-
"com.google.code.gson:gson:2.9.0",
6369
"com.google.guava:failureaccess:1.0.1",
64-
"com.google.j2objc:j2objc-annotations:1.3",
65-
"com.google.re2j:re2j:1.6",
66-
"com.google.truth:truth:1.0.1",
67-
"com.squareup.okhttp:okhttp:2.7.5",
68-
"com.squareup.okio:okio:1.17.5",
69-
"io.netty:netty-buffer",
70-
"io.netty:netty-codec-http2",
71-
"io.netty:netty-codec-http",
72-
"io.netty:netty-codec-socks",
73-
"io.netty:netty-codec",
74-
"io.netty:netty-common",
75-
"io.netty:netty-handler-proxy",
76-
"io.netty:netty-handler",
77-
"io.netty:netty-resolver",
78-
"io.netty:netty-tcnative-boringssl-static:2.0.56.Final",
79-
"io.netty:netty-tcnative-classes:2.0.56.Final",
80-
"io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.87.Final",
81-
"io.netty:netty-transport-native-unix-common",
82-
"io.netty:netty-transport",
83-
"io.opencensus:opencensus-api:0.24.0",
84-
"io.opencensus:opencensus-contrib-grpc-metrics:0.24.0",
85-
"io.perfmark:perfmark-api:0.25.0",
86-
"junit:junit:4.12",
8770
"org.apache.tomcat:annotations-api:6.0.53",
8871
"org.codehaus.mojo:animal-sniffer-annotations:1.21",
8972
]
@@ -137,14 +120,11 @@ maven.install(
137120
] + IO_GRPC_GRPC_JAVA_ARTIFACTS,
138121
boms = [
139122
"io.grpc:grpc-bom:1.68.2",
140-
"io.netty:netty-bom:4.1.87.Final",
141123
"org.junit:junit-bom:5.11.3",
142124
],
143125
fail_if_repin_required = True,
144-
generate_compat_repositories = True,
145126
lock_file = "//:contrib_rules_jvm_deps_install.json",
146127
resolver = "maven",
147-
strict_visibility = False,
148128
)
149129

150130
# Spotbugs deps
@@ -159,17 +139,7 @@ maven.artifact(
159139
group = "com.github.spotbugs",
160140
version = spotbugs_version,
161141
)
162-
use_repo(
163-
maven,
164-
"com_google_api_grpc_proto_google_common_protos",
165-
"com_google_code_findbugs_jsr305",
166-
"com_google_errorprone_error_prone_annotations",
167-
"com_google_guava_failureaccess",
168-
"com_google_guava_guava",
169-
"com_google_j2objc_j2objc_annotations",
170-
"contrib_rules_jvm_deps",
171-
"org_apache_tomcat_annotations_api",
172-
)
142+
use_repo(maven, "contrib_rules_jvm_deps")
173143

174144
dev_maven = use_extension(
175145
"@rules_jvm_external//:extensions.bzl",

0 commit comments

Comments
 (0)