Allow building third-party apps based on gRPC

By publishing the repackaged grpc and protobuf artifacts

Change-Id: Ib3af7dba4f64948132aa70be31922de61d6f6ab2
diff --git a/protocols/grpc/BUILD b/protocols/grpc/BUILD
index 3dd1084..59a99f0 100644
--- a/protocols/grpc/BUILD
+++ b/protocols/grpc/BUILD
@@ -1,19 +1,15 @@
-load("//tools/build/bazel:osgi_java_library.bzl", "wrapped_osgi_jar")
-load("//tools/build/bazel:variables.bzl", "GRPC_JAVA_VERSION")
-load("//tools/build/bazel:variables.bzl", "PROTOBUF_VERSION")
-
 BUNDLES = [
     "//protocols/grpc/api:onos-protocols-grpc-api",
     "//protocols/grpc/ctl:onos-protocols-grpc-ctl",
     "//protocols/grpc/utils:onos-protocols-grpc-utils",
     # gRPC dependencies (with patched core)
-    ":grpc-core",
-    ":grpc-stub",
-    ":grpc-netty",
-    ":grpc-auth",
-    ":grpc-protobuf",
-    ":grpc-protobuf-lite",
-    ":protobuf-java",
+    "//lib:io_grpc_grpc_core_context",
+    "//lib:io_grpc_grpc_stub",
+    "//lib:io_grpc_grpc_netty",
+    "//lib:io_grpc_grpc_auth",
+    "//lib:io_grpc_grpc_protobuf",
+    "//lib:io_grpc_grpc_protobuf_lite",
+    "//lib:com_google_protobuf_protobuf_java",
     "@com_google_api_grpc_proto_google_common_protos//jar",
     "@com_google_errorprone_error_prone_annotations//jar",
     "@com_google_auth_google_auth_library_credentials//jar",
@@ -30,83 +26,3 @@
     title = "gRPC Protocol Subsystem",
     url = "ttp://onosproject.org",
 )
-
-# Wrap protobuf and grpc-related JARs in OSGi-compatible ones, since the
-# original ones 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.
-
-GRPC_GROUP_ID = "io.grpc"
-
-PROTOBUF_GROUP_ID = "com.google.protobuf"
-
-wrapped_osgi_jar(
-    # 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-core",
-    group = GRPC_GROUP_ID,
-    jar = "@io_grpc_grpc_java//core",
-    version = GRPC_JAVA_VERSION,
-    visibility = ["//visibility:public"],
-    deps = [],
-)
-
-wrapped_osgi_jar(
-    name = "grpc-stub",
-    group = GRPC_GROUP_ID,
-    jar = "@io_grpc_grpc_java//stub",
-    version = GRPC_JAVA_VERSION,
-    visibility = ["//visibility:public"],
-    deps = [],
-)
-
-wrapped_osgi_jar(
-    name = "grpc-netty",
-    group = GRPC_GROUP_ID,
-    jar = "@io_grpc_grpc_java//netty",
-    version = GRPC_JAVA_VERSION,
-    visibility = ["//visibility:public"],
-    deps = [],
-)
-
-wrapped_osgi_jar(
-    name = "grpc-auth",
-    group = GRPC_GROUP_ID,
-    jar = "@io_grpc_grpc_java//auth",
-    version = GRPC_JAVA_VERSION,
-    visibility = ["//visibility:public"],
-    deps = [],
-)
-
-wrapped_osgi_jar(
-    name = "grpc-protobuf",
-    group = GRPC_GROUP_ID,
-    jar = "@io_grpc_grpc_java//protobuf",
-    version = GRPC_JAVA_VERSION,
-    visibility = ["//visibility:public"],
-    deps = [],
-)
-
-wrapped_osgi_jar(
-    name = "grpc-protobuf-lite",
-    group = GRPC_GROUP_ID,
-    jar = "@io_grpc_grpc_java//protobuf-lite",
-    version = GRPC_JAVA_VERSION,
-    visibility = ["//visibility:public"],
-    deps = [],
-)
-
-wrapped_osgi_jar(
-    name = "protobuf-java",
-    group = PROTOBUF_GROUP_ID,
-    jar = "@com_google_protobuf//:protobuf_java",
-    version = PROTOBUF_VERSION,
-    visibility = ["//visibility:public"],
-    deps = [],
-)
diff --git a/protocols/grpc/api/BUILD b/protocols/grpc/api/BUILD
index 55e2b4a..5a2b2d7 100644
--- a/protocols/grpc/api/BUILD
+++ b/protocols/grpc/api/BUILD
@@ -1,3 +1,3 @@
 osgi_jar(
-    deps = CORE_DEPS + ["@io_grpc_grpc_java//core"],
+    deps = CORE_DEPS + ["//lib:io_grpc_grpc_core_context"],
 )
diff --git a/protocols/grpc/ctl/BUILD b/protocols/grpc/ctl/BUILD
index fa10ff3..16676c5 100644
--- a/protocols/grpc/ctl/BUILD
+++ b/protocols/grpc/ctl/BUILD
@@ -1,9 +1,9 @@
 COMPILE_DEPS = CORE_DEPS + [
     "//protocols/grpc/api:onos-protocols-grpc-api",
-    "@io_grpc_grpc_java//core",
-    "@io_grpc_grpc_java//netty",
-    "@io_grpc_grpc_java//protobuf-lite",
-    "@com_google_protobuf//:protobuf_java",
+    "//lib:io_grpc_grpc_core_context",
+    "//lib:io_grpc_grpc_netty",
+    "//lib:io_grpc_grpc_protobuf_lite",
+    "//lib:com_google_protobuf_protobuf_java",
     "@com_google_api_grpc_proto_google_common_protos//jar",
     "@io_netty_netty_handler//jar",
 ]
diff --git a/protocols/grpc/utils/BUILD b/protocols/grpc/utils/BUILD
index 7baaf52..25a78ad 100644
--- a/protocols/grpc/utils/BUILD
+++ b/protocols/grpc/utils/BUILD
@@ -1,6 +1,6 @@
 COMPILE_DEPS = CORE_DEPS + [
     "//protocols/grpc/api:onos-protocols-grpc-api",
-    "@io_grpc_grpc_java//core",
+    "//lib:io_grpc_grpc_core_context",
 ]
 
 osgi_jar(