Skip to content

Commit ea09d3e

Browse files
committed
Add Bazel build support for xds, googleapis to flesh out maven_install
Not updating the example WORKSPACE because it doesn't have any Bazel-enabled build that depends on xds and so doesn't need the additional repository dependencies. Fixes #9162
1 parent 1d4e82e commit ea09d3e

File tree

7 files changed

+340
-27
lines changed

7 files changed

+340
-27
lines changed

BUILD.bazel

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,18 @@ java_library(
5151
"@com_google_guava_guava//jar",
5252
],
5353
)
54+
55+
java_plugin(
56+
name = "auto_value",
57+
generates_api = 1,
58+
processor_class = "com.google.auto.value.processor.AutoValueProcessor",
59+
deps = ["@com_google_auto_value_auto_value//jar"],
60+
)
61+
62+
java_library(
63+
name = "auto_value_annotations",
64+
exported_plugins = [":auto_value"],
65+
neverlink = 1,
66+
visibility = ["//:__subpackages__"],
67+
exports = ["@com_google_auto_value_auto_value_annotations//jar"],
68+
)

WORKSPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
2121

2222
protobuf_deps()
2323

24+
load("@envoy_api//bazel:repositories.bzl", "api_dependencies")
25+
26+
api_dependencies()
27+
28+
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
29+
30+
switched_rules_by_language(
31+
name = "com_google_googleapis_imports",
32+
java = True,
33+
)
34+
2435
maven_install(
2536
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS + PROTOBUF_MAVEN_ARTIFACTS,
2637
generate_compat_repositories = True,

googleapis/BUILD.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
java_library(
2+
name = "googleapis",
3+
srcs = glob([
4+
"src/main/java/**/*.java",
5+
]),
6+
visibility = ["//visibility:public"],
7+
deps = [
8+
"//alts",
9+
"//api",
10+
"//core:internal",
11+
"//xds",
12+
"@com_google_guava_guava//jar",
13+
],
14+
)

repositories.bzl

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [
1414
"com.google.api.grpc:proto-google-common-protos:2.0.1",
1515
"com.google.auth:google-auth-library-credentials:0.22.0",
1616
"com.google.auth:google-auth-library-oauth2-http:0.22.0",
17+
"com.google.auto.value:auto-value-annotations:1.9",
18+
"com.google.auto.value:auto-value:1.9",
1719
"com.google.code.findbugs:jsr305:3.0.2",
1820
"com.google.code.gson:gson:2.8.9",
19-
"com.google.auto.value:auto-value:1.7.4",
20-
"com.google.auto.value:auto-value-annotations:1.7.4",
2121
"com.google.errorprone:error_prone_annotations:2.9.0",
2222
"com.google.guava:failureaccess:1.0.1",
2323
"com.google.guava:guava:31.0.1-android",
2424
"com.google.j2objc:j2objc-annotations:1.3",
25+
"com.google.re2j:re2j:1.5",
2526
"com.google.truth:truth:1.0.1",
2627
"com.squareup.okhttp:okhttp:2.7.4",
2728
"com.squareup.okio:okio:1.17.5",
@@ -73,24 +74,73 @@ IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS = {
7374
"io.grpc:grpc-census": "@io_grpc_grpc_java//census",
7475
"io.grpc:grpc-context": "@io_grpc_grpc_java//context",
7576
"io.grpc:grpc-core": "@io_grpc_grpc_java//core:core_maven",
77+
"io.grpc:grpc-googleapis": "@io_grpc_grpc_java//googleapis",
7678
"io.grpc:grpc-grpclb": "@io_grpc_grpc_java//grpclb",
7779
"io.grpc:grpc-netty": "@io_grpc_grpc_java//netty",
7880
"io.grpc:grpc-netty-shaded": "@io_grpc_grpc_java//netty:shaded_maven",
7981
"io.grpc:grpc-okhttp": "@io_grpc_grpc_java//okhttp",
8082
"io.grpc:grpc-protobuf": "@io_grpc_grpc_java//protobuf",
8183
"io.grpc:grpc-protobuf-lite": "@io_grpc_grpc_java//protobuf-lite",
84+
"io.grpc:grpc-rls": "@io_grpc_grpc_java//rls",
85+
"io.grpc:grpc-services": "@io_grpc_grpc_java//services",
8286
"io.grpc:grpc-stub": "@io_grpc_grpc_java//stub",
8387
"io.grpc:grpc-testing": "@io_grpc_grpc_java//testing",
88+
"io.grpc:grpc-xds": "@io_grpc_grpc_java//xds",
8489
}
8590

8691
def grpc_java_repositories():
8792
"""Imports dependencies for grpc-java."""
93+
if not native.existing_rule("com_github_cncf_xds"):
94+
http_archive(
95+
name = "com_github_cncf_xds",
96+
strip_prefix = "xds-d92e9ce0af512a73a3a126b32fa4920bee12e180",
97+
sha256 = "27be88b1ff2844885d3b2d0d579546f3a8b3f26b4871eed89082c9709e49a4bd",
98+
urls = [
99+
"https://github.com/cncf/xds/archive/d92e9ce0af512a73a3a126b32fa4920bee12e180.tar.gz",
100+
],
101+
)
102+
if not native.existing_rule("com_github_grpc_grpc"):
103+
http_archive(
104+
name = "com_github_grpc_grpc",
105+
strip_prefix = "grpc-1.46.0",
106+
sha256 = "67423a4cd706ce16a88d1549297023f0f9f0d695a96dd684adc21e67b021f9bc",
107+
urls = [
108+
"https://github.com/grpc/grpc/archive/v1.46.0.tar.gz",
109+
],
110+
)
88111
if not native.existing_rule("com_google_protobuf"):
89112
com_google_protobuf()
90113
if not native.existing_rule("com_google_protobuf_javalite"):
91114
com_google_protobuf_javalite()
115+
if not native.existing_rule("com_google_googleapis"):
116+
http_archive(
117+
name = "com_google_googleapis",
118+
sha256 = "49930468563dd48283e8301e8d4e71436bf6d27ac27c235224cc1a098710835d",
119+
strip_prefix = "googleapis-ca1372c6d7bcb199638ebfdb40d2b2660bab7b88",
120+
urls = [
121+
"https://github.com/googleapis/googleapis/archive/ca1372c6d7bcb199638ebfdb40d2b2660bab7b88.tar.gz",
122+
],
123+
)
124+
if not native.existing_rule("io_bazel_rules_go"):
125+
http_archive(
126+
name = "io_bazel_rules_go",
127+
sha256 = "ab21448cef298740765f33a7f5acee0607203e4ea321219f2a4c85a6e0fb0a27",
128+
urls = [
129+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.32.0/rules_go-v0.32.0.zip",
130+
"https://github.com/bazelbuild/rules_go/releases/download/v0.32.0/rules_go-v0.32.0.zip",
131+
],
132+
)
92133
if not native.existing_rule("io_grpc_grpc_proto"):
93134
io_grpc_grpc_proto()
135+
if not native.existing_rule("envoy_api"):
136+
http_archive(
137+
name = "envoy_api",
138+
sha256 = "621577591d48cee20b61d4e71466bf4019791f9991da4813ccf75f3b9898de5f",
139+
strip_prefix = "data-plane-api-bb6d6abe8b4d035c2f4ba3acf924cec0cbec5f70",
140+
urls = [
141+
"https://github.com/envoyproxy/data-plane-api/archive/bb6d6abe8b4d035c2f4ba3acf924cec0cbec5f70.tar.gz",
142+
],
143+
)
94144

95145
def com_google_protobuf():
96146
# proto_library rules implicitly depend on @com_google_protobuf//:protoc,

rls/BUILD.bazel

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ java_library(
77
]),
88
visibility = ["//visibility:public"],
99
deps = [
10-
":autovalue",
1110
":rls_java_grpc",
11+
"//:auto_value_annotations",
1212
"//api",
1313
"//core",
1414
"//core:internal",
@@ -17,27 +17,8 @@ java_library(
1717
"@com_google_auto_value_auto_value_annotations//jar",
1818
"@com_google_code_findbugs_jsr305//jar",
1919
"@com_google_guava_guava//jar",
20-
"@io_grpc_grpc_proto//:rls_java_proto",
2120
"@io_grpc_grpc_proto//:rls_config_java_proto",
22-
],
23-
)
24-
25-
java_plugin(
26-
name = "autovalue_plugin",
27-
processor_class = "com.google.auto.value.processor.AutoValueProcessor",
28-
deps = [
29-
"@com_google_auto_value_auto_value//jar",
30-
],
31-
)
32-
33-
java_library(
34-
name = "autovalue",
35-
exported_plugins = [
36-
":autovalue_plugin",
37-
],
38-
neverlink = 1,
39-
exports = [
40-
"@com_google_auto_value_auto_value//jar",
21+
"@io_grpc_grpc_proto//:rls_java_proto",
4122
],
4223
)
4324

services/BUILD.bazel

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,75 @@ load("//:java_grpc_library.bzl", "java_grpc_library")
22

33
package(default_visibility = ["//visibility:public"])
44

5+
# Mirrors the dependencies included in the artifact on Maven Central for usage
6+
# with maven_install's override_targets. Purposefully does not export any
7+
# symbols, as it should only be used as a dep for pre-compiled binaries on
8+
# Maven Central.
9+
java_library(
10+
name = "services_maven",
11+
runtime_deps = [
12+
":admin",
13+
":binarylog",
14+
":channelz",
15+
":health",
16+
":healthlb",
17+
":metrics",
18+
":metrics_internal",
19+
":reflection",
20+
],
21+
)
22+
23+
java_library(
24+
name = "admin",
25+
srcs = [
26+
"src/main/java/io/grpc/services/AdminInterface.java",
27+
],
28+
deps = [
29+
":channelz",
30+
"//api",
31+
"@com_google_code_findbugs_jsr305//jar",
32+
],
33+
)
34+
35+
java_library(
36+
name = "metrics",
37+
srcs = [
38+
"src/main/java/io/grpc/services/CallMetricRecorder.java",
39+
"src/main/java/io/grpc/services/MetricRecorder.java",
40+
],
41+
deps = [
42+
"//api",
43+
"//context",
44+
"@com_google_code_findbugs_jsr305//jar",
45+
"@com_google_guava_guava//jar",
46+
],
47+
)
48+
49+
java_library(
50+
name = "metrics_internal",
51+
srcs = [
52+
"src/main/java/io/grpc/services/InternalCallMetricRecorder.java",
53+
"src/main/java/io/grpc/services/InternalMetricRecorder.java",
54+
],
55+
visibility = ["//:__subpackages__"],
56+
deps = [
57+
":metrics",
58+
"//api",
59+
"//context",
60+
],
61+
)
62+
563
java_library(
664
name = "binarylog",
765
srcs = [
866
"src/main/java/io/grpc/protobuf/services/BinaryLogProvider.java",
967
"src/main/java/io/grpc/protobuf/services/BinaryLogProviderImpl.java",
1068
"src/main/java/io/grpc/protobuf/services/BinaryLogSink.java",
69+
"src/main/java/io/grpc/protobuf/services/BinaryLogs.java",
1170
"src/main/java/io/grpc/protobuf/services/BinlogHelper.java",
1271
"src/main/java/io/grpc/protobuf/services/InetAddressUtil.java",
1372
"src/main/java/io/grpc/protobuf/services/TempFileSink.java",
73+
"src/main/java/io/grpc/services/BinaryLogs.java",
1474
],
1575
deps = [
1676
"//api",
@@ -33,7 +93,6 @@ java_library(
3393
deps = [
3494
":_channelz_java_grpc",
3595
"//api",
36-
"//context",
3796
"//stub",
3897
"@com_google_code_findbugs_jsr305//jar",
3998
"@com_google_guava_guava//jar",
@@ -51,9 +110,6 @@ java_library(
51110
deps = [
52111
":_reflection_java_grpc",
53112
"//api",
54-
"//context",
55-
"//core:internal",
56-
"//core:util",
57113
"//protobuf",
58114
"//stub",
59115
"@com_google_code_findbugs_jsr305//jar",
@@ -82,6 +138,27 @@ java_library(
82138
],
83139
)
84140

141+
java_library(
142+
name = "healthlb",
143+
srcs = [
144+
"src/main/java/io/grpc/protobuf/services/HealthCheckingLoadBalancerFactory.java",
145+
"src/main/java/io/grpc/protobuf/services/HealthCheckingLoadBalancerUtil.java",
146+
"src/main/java/io/grpc/protobuf/services/internal/HealthCheckingRoundRobinLoadBalancerProvider.java",
147+
],
148+
resources = [
149+
"src/main/resources/META-INF/services/io.grpc.LoadBalancerProvider",
150+
],
151+
deps = [
152+
":_health_java_grpc",
153+
"//api",
154+
"//core:internal",
155+
"//core:util",
156+
"@com_google_code_findbugs_jsr305//jar",
157+
"@com_google_guava_guava//jar",
158+
"@io_grpc_grpc_proto//:health_java_proto",
159+
],
160+
)
161+
85162
# These shouldn't be here, but this is better than having
86163
# a circular dependency on grpc-proto and grpc-java.
87164

0 commit comments

Comments
 (0)