Skip to content
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

Add Bazel build support for xds, googleapis to flesh out maven_install #9172

Merged
merged 1 commit into from May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions BUILD.bazel
Expand Up @@ -51,3 +51,18 @@ java_library(
"@com_google_guava_guava//jar",
],
)

java_plugin(
name = "auto_value",
generates_api = 1,
processor_class = "com.google.auto.value.processor.AutoValueProcessor",
deps = ["@com_google_auto_value_auto_value//jar"],
)

java_library(
name = "auto_value_annotations",
exported_plugins = [":auto_value"],
neverlink = 1,
visibility = ["//:__subpackages__"],
exports = ["@com_google_auto_value_auto_value_annotations//jar"],
)
11 changes: 11 additions & 0 deletions WORKSPACE
Expand Up @@ -21,6 +21,17 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

load("@envoy_api//bazel:repositories.bzl", "api_dependencies")

api_dependencies()

load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")

switched_rules_by_language(
name = "com_google_googleapis_imports",
java = True,
)

maven_install(
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS + PROTOBUF_MAVEN_ARTIFACTS,
generate_compat_repositories = True,
Expand Down
14 changes: 14 additions & 0 deletions googleapis/BUILD.bazel
@@ -0,0 +1,14 @@
java_library(
name = "googleapis",
srcs = glob([
"src/main/java/**/*.java",
]),
visibility = ["//visibility:public"],
deps = [
"//alts",
"//api",
"//core:internal",
"//xds",
"@com_google_guava_guava//jar",
],
)
54 changes: 52 additions & 2 deletions repositories.bzl
Expand Up @@ -14,14 +14,15 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [
"com.google.api.grpc:proto-google-common-protos:2.0.1",
"com.google.auth:google-auth-library-credentials:0.22.0",
"com.google.auth:google-auth-library-oauth2-http:0.22.0",
"com.google.auto.value:auto-value-annotations:1.9",
"com.google.auto.value:auto-value:1.9",
"com.google.code.findbugs:jsr305:3.0.2",
"com.google.code.gson:gson:2.8.9",
"com.google.auto.value:auto-value:1.7.4",
"com.google.auto.value:auto-value-annotations:1.7.4",
"com.google.errorprone:error_prone_annotations:2.9.0",
"com.google.guava:failureaccess:1.0.1",
"com.google.guava:guava:31.0.1-android",
"com.google.j2objc:j2objc-annotations:1.3",
"com.google.re2j:re2j:1.5",
"com.google.truth:truth:1.0.1",
"com.squareup.okhttp:okhttp:2.7.4",
"com.squareup.okio:okio:1.17.5",
Expand Down Expand Up @@ -73,24 +74,73 @@ IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS = {
"io.grpc:grpc-census": "@io_grpc_grpc_java//census",
"io.grpc:grpc-context": "@io_grpc_grpc_java//context",
"io.grpc:grpc-core": "@io_grpc_grpc_java//core:core_maven",
"io.grpc:grpc-googleapis": "@io_grpc_grpc_java//googleapis",
"io.grpc:grpc-grpclb": "@io_grpc_grpc_java//grpclb",
"io.grpc:grpc-netty": "@io_grpc_grpc_java//netty",
"io.grpc:grpc-netty-shaded": "@io_grpc_grpc_java//netty:shaded_maven",
"io.grpc:grpc-okhttp": "@io_grpc_grpc_java//okhttp",
"io.grpc:grpc-protobuf": "@io_grpc_grpc_java//protobuf",
"io.grpc:grpc-protobuf-lite": "@io_grpc_grpc_java//protobuf-lite",
"io.grpc:grpc-rls": "@io_grpc_grpc_java//rls",
"io.grpc:grpc-services": "@io_grpc_grpc_java//services",
"io.grpc:grpc-stub": "@io_grpc_grpc_java//stub",
"io.grpc:grpc-testing": "@io_grpc_grpc_java//testing",
"io.grpc:grpc-xds": "@io_grpc_grpc_java//xds",
}

def grpc_java_repositories():
"""Imports dependencies for grpc-java."""
if not native.existing_rule("com_github_cncf_xds"):
http_archive(
name = "com_github_cncf_xds",
strip_prefix = "xds-d92e9ce0af512a73a3a126b32fa4920bee12e180",
sha256 = "27be88b1ff2844885d3b2d0d579546f3a8b3f26b4871eed89082c9709e49a4bd",
urls = [
"https://github.com/cncf/xds/archive/d92e9ce0af512a73a3a126b32fa4920bee12e180.tar.gz",
],
)
if not native.existing_rule("com_github_grpc_grpc"):
http_archive(
name = "com_github_grpc_grpc",
strip_prefix = "grpc-1.46.0",
sha256 = "67423a4cd706ce16a88d1549297023f0f9f0d695a96dd684adc21e67b021f9bc",
urls = [
"https://github.com/grpc/grpc/archive/v1.46.0.tar.gz",
],
)
if not native.existing_rule("com_google_protobuf"):
com_google_protobuf()
if not native.existing_rule("com_google_protobuf_javalite"):
com_google_protobuf_javalite()
if not native.existing_rule("com_google_googleapis"):
http_archive(
name = "com_google_googleapis",
sha256 = "49930468563dd48283e8301e8d4e71436bf6d27ac27c235224cc1a098710835d",
strip_prefix = "googleapis-ca1372c6d7bcb199638ebfdb40d2b2660bab7b88",
urls = [
"https://github.com/googleapis/googleapis/archive/ca1372c6d7bcb199638ebfdb40d2b2660bab7b88.tar.gz",
],
)
if not native.existing_rule("io_bazel_rules_go"):
http_archive(
name = "io_bazel_rules_go",
sha256 = "ab21448cef298740765f33a7f5acee0607203e4ea321219f2a4c85a6e0fb0a27",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.32.0/rules_go-v0.32.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.32.0/rules_go-v0.32.0.zip",
],
)
if not native.existing_rule("io_grpc_grpc_proto"):
io_grpc_grpc_proto()
if not native.existing_rule("envoy_api"):
http_archive(
name = "envoy_api",
sha256 = "621577591d48cee20b61d4e71466bf4019791f9991da4813ccf75f3b9898de5f",
strip_prefix = "data-plane-api-bb6d6abe8b4d035c2f4ba3acf924cec0cbec5f70",
urls = [
"https://github.com/envoyproxy/data-plane-api/archive/bb6d6abe8b4d035c2f4ba3acf924cec0cbec5f70.tar.gz",
],
)

def com_google_protobuf():
# proto_library rules implicitly depend on @com_google_protobuf//:protoc,
Expand Down
23 changes: 2 additions & 21 deletions rls/BUILD.bazel
Expand Up @@ -7,8 +7,8 @@ java_library(
]),
visibility = ["//visibility:public"],
deps = [
":autovalue",
":rls_java_grpc",
"//:auto_value_annotations",
"//api",
"//core",
"//core:internal",
Expand All @@ -17,27 +17,8 @@ java_library(
"@com_google_auto_value_auto_value_annotations//jar",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_guava_guava//jar",
"@io_grpc_grpc_proto//:rls_java_proto",
"@io_grpc_grpc_proto//:rls_config_java_proto",
],
)

java_plugin(
name = "autovalue_plugin",
processor_class = "com.google.auto.value.processor.AutoValueProcessor",
deps = [
"@com_google_auto_value_auto_value//jar",
],
)

java_library(
name = "autovalue",
exported_plugins = [
":autovalue_plugin",
],
neverlink = 1,
exports = [
"@com_google_auto_value_auto_value//jar",
"@io_grpc_grpc_proto//:rls_java_proto",
],
)

Expand Down
85 changes: 81 additions & 4 deletions services/BUILD.bazel
Expand Up @@ -2,15 +2,75 @@ load("//:java_grpc_library.bzl", "java_grpc_library")

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

# Mirrors the dependencies included in the artifact on Maven Central for usage
# with maven_install's override_targets. Purposefully does not export any
# symbols, as it should only be used as a dep for pre-compiled binaries on
# Maven Central.
java_library(
name = "services_maven",
runtime_deps = [
":admin",
":binarylog",
":channelz",
":health",
":healthlb",
":metrics",
":metrics_internal",
":reflection",
],
)

java_library(
name = "admin",
srcs = [
"src/main/java/io/grpc/services/AdminInterface.java",
],
deps = [
":channelz",
"//api",
"@com_google_code_findbugs_jsr305//jar",
],
)

java_library(
name = "metrics",
srcs = [
"src/main/java/io/grpc/services/CallMetricRecorder.java",
"src/main/java/io/grpc/services/MetricRecorder.java",
],
deps = [
"//api",
"//context",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_guava_guava//jar",
],
)

java_library(
name = "metrics_internal",
srcs = [
"src/main/java/io/grpc/services/InternalCallMetricRecorder.java",
"src/main/java/io/grpc/services/InternalMetricRecorder.java",
],
visibility = ["//:__subpackages__"],
deps = [
":metrics",
"//api",
"//context",
],
)

java_library(
name = "binarylog",
srcs = [
"src/main/java/io/grpc/protobuf/services/BinaryLogProvider.java",
"src/main/java/io/grpc/protobuf/services/BinaryLogProviderImpl.java",
"src/main/java/io/grpc/protobuf/services/BinaryLogSink.java",
"src/main/java/io/grpc/protobuf/services/BinaryLogs.java",
"src/main/java/io/grpc/protobuf/services/BinlogHelper.java",
"src/main/java/io/grpc/protobuf/services/InetAddressUtil.java",
"src/main/java/io/grpc/protobuf/services/TempFileSink.java",
"src/main/java/io/grpc/services/BinaryLogs.java",
],
deps = [
"//api",
Expand All @@ -33,7 +93,6 @@ java_library(
deps = [
":_channelz_java_grpc",
"//api",
"//context",
"//stub",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_guava_guava//jar",
Expand All @@ -51,9 +110,6 @@ java_library(
deps = [
":_reflection_java_grpc",
"//api",
"//context",
"//core:internal",
"//core:util",
"//protobuf",
"//stub",
"@com_google_code_findbugs_jsr305//jar",
Expand Down Expand Up @@ -82,6 +138,27 @@ java_library(
],
)

java_library(
name = "healthlb",
srcs = [
"src/main/java/io/grpc/protobuf/services/HealthCheckingLoadBalancerFactory.java",
"src/main/java/io/grpc/protobuf/services/HealthCheckingLoadBalancerUtil.java",
"src/main/java/io/grpc/protobuf/services/internal/HealthCheckingRoundRobinLoadBalancerProvider.java",
],
resources = [
"src/main/resources/META-INF/services/io.grpc.LoadBalancerProvider",
],
deps = [
":_health_java_grpc",
"//api",
"//core:internal",
"//core:util",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_guava_guava//jar",
"@io_grpc_grpc_proto//:health_java_proto",
],
)

# These shouldn't be here, but this is better than having
# a circular dependency on grpc-proto and grpc-java.

Expand Down