Fix build of protobuf-related components to support Bazel 0.22
- Bumped version of protobuf to 3.6.1.3 (includes fix for Bazel 0.22)
- Removed all protobuf and grpc dependencies from deps.json. Instead,
depends solely on what's provided by the external grpc and protobuf
workspaces.
- Use OSGi-wrapped protobuf and grpc JARs built with Bazel for runtime
- Add missing netty-related bundles to onos-thirdparty-base (required
by grpc)
Note, build with Bazel 0.22 is still broken because of
osgi_java_library.bzl, unless the following build arg is used:
build --incompatible_string_is_not_iterable=false
It seems the error is caused by dead code in osgi_java_library.bzl
that should be removed.
Change-Id: I749f1de25902bf9df5242444380f7224bc99b4b5
diff --git a/protocols/grpc/BUILD b/protocols/grpc/BUILD
index 26e178c..3d46f95 100644
--- a/protocols/grpc/BUILD
+++ b/protocols/grpc/BUILD
@@ -5,31 +5,19 @@
"//protocols/grpc/api:onos-protocols-grpc-api",
"//protocols/grpc/ctl:onos-protocols-grpc-ctl",
# gRPC dependencies (with patched core)
- ":grpc-core-repkg",
- "@runtime_grpc_stub//jar",
- "@runtime_grpc_netty//jar",
- "@runtime_grpc_auth//jar",
- "@runtime_grpc_protobuf//jar",
- "@runtime_grpc_protobuf_lite//jar",
- "@runtime_protobuf//jar",
+ ":grpc-bundle-core",
+ ":grpc-bundle-stub",
+ ":grpc-bundle-netty",
+ ":grpc-bundle-auth",
+ ":grpc-bundle-protobuf",
+ ":grpc-bundle-protobuf-lite",
+ ":protobuf-java-bundle",
"@com_google_api_grpc_proto_google_common_protos//jar",
"@com_google_errorprone_error_prone_annotations//jar",
"@com_google_auth_google_auth_library_credentials//jar",
"@io_opencensus_opencensus_api//jar",
"@io_opencensus_opencensus_contrib_grpc_metrics//jar",
"@com_google_code_gson_gson//jar",
- # Lazily adding all netty-related packages.
- # Some of them might not be necessary.
- "@io_netty_netty//jar",
- "@io_netty_netty_buffer//jar",
- "@io_netty_netty_codec//jar",
- "@io_netty_netty_codec_http//jar",
- "@io_netty_netty_codec_http2//jar",
- "@io_netty_netty_common//jar",
- "@io_netty_netty_handler//jar",
- "@io_netty_netty_transport//jar",
- "@io_netty_netty_transport_native_epoll//jar",
- "@io_netty_netty_resolver//jar",
]
onos_app(
@@ -41,9 +29,64 @@
url = "ttp://onosproject.org",
)
+# Wrap protobuf and grpc-related JARs in OSGi-compatible ones, since the
+# original one are built with Bazel and NOT imported via mvn.
+
+# FIXME: consider moving these rules somewhere else as other apps depend on it
+# (e.g. openstacktelemetry and kafka-integration) but they don't directly
+# depend on any onos-protocols-grpc-* module.
+
wrapped_osgi_jar(
- name = "grpc-core-repkg",
+ # Differently from the official "grpc-core" package, here we also include
+ # "grpc-context" to solve the OSGI split-brain problem:
+ # https://github.com/grpc/grpc-java/issues/2727
+ # We use patched Bazel BUILD files to package together core and context (see
+ # tools/build/bazel/grpc_workspace.bzl). If you need grpc-context as a
+ # compile-time dependency, please use this one.
+ name = "grpc-bundle-core",
jar = "@io_grpc_grpc_java//core",
visibility = ["//visibility:public"],
- deps = ["@io_opencensus_opencensus_api//jar"],
+ deps = [],
+)
+
+wrapped_osgi_jar(
+ name = "grpc-bundle-stub",
+ jar = "@io_grpc_grpc_java//stub",
+ visibility = ["//visibility:public"],
+ deps = [],
+)
+
+wrapped_osgi_jar(
+ name = "grpc-bundle-netty",
+ jar = "@io_grpc_grpc_java//netty",
+ visibility = ["//visibility:public"],
+ deps = [],
+)
+
+wrapped_osgi_jar(
+ name = "grpc-bundle-auth",
+ jar = "@io_grpc_grpc_java//auth",
+ visibility = ["//visibility:public"],
+ deps = [],
+)
+
+wrapped_osgi_jar(
+ name = "grpc-bundle-protobuf",
+ jar = "@io_grpc_grpc_java//protobuf",
+ visibility = ["//visibility:public"],
+ deps = [],
+)
+
+wrapped_osgi_jar(
+ name = "grpc-bundle-protobuf-lite",
+ jar = "@io_grpc_grpc_java//protobuf-lite",
+ visibility = ["//visibility:public"],
+ deps = [],
+)
+
+wrapped_osgi_jar(
+ name = "protobuf-java-bundle",
+ jar = "@com_google_protobuf//:protobuf_java",
+ visibility = ["//visibility:public"],
+ deps = [],
)