Allow building third-party apps based on gRPC

By publishing the repackaged grpc and protobuf artifacts

Change-Id: Ib3af7dba4f64948132aa70be31922de61d6f6ab2
diff --git a/apps/kafka-integration/BUILD b/apps/kafka-integration/BUILD
index 62c1293..6daeb1a 100644
--- a/apps/kafka-integration/BUILD
+++ b/apps/kafka-integration/BUILD
@@ -1,6 +1,6 @@
 BUNDLES = [
     "@kafka_clients//jar",
-    "//protocols/grpc:protobuf-java",
+    "//lib:com_google_protobuf_protobuf_java",
     "//core/protobuf/models:onos-core-protobuf-models",
     "//core/protobuf/models/proto:onos-core-protobuf-models-proto",
     "//apps/kafka-integration/api:onos-apps-kafka-integration-api",
diff --git a/apps/kafka-integration/app/BUILD b/apps/kafka-integration/app/BUILD
index 5d1f1ed..4cf8eaa 100644
--- a/apps/kafka-integration/app/BUILD
+++ b/apps/kafka-integration/app/BUILD
@@ -4,7 +4,7 @@
     "@kafka_clients//jar",
     "@javax_ws_rs_api//jar",
     "//utils/rest:onlab-rest",
-    "@com_google_protobuf//:protobuf_java",
+    "//lib:com_google_protobuf_protobuf_java",
     "//core/protobuf/models:onos-core-protobuf-models",
     "//core/protobuf/models/proto:onos-core-protobuf-models-proto",
 ]
diff --git a/apps/onlp-demo/BUILD b/apps/onlp-demo/BUILD
index 960a820..2ef30c2 100644
--- a/apps/onlp-demo/BUILD
+++ b/apps/onlp-demo/BUILD
@@ -1,8 +1,8 @@
 COMPILE_DEPS = CORE_DEPS + JACKSON + [
-    "@com_google_protobuf//:protobuf_java",
-    "@io_grpc_grpc_java//core",
-    "@io_grpc_grpc_java//netty",
-    "@io_grpc_grpc_java//stub",
+    "//lib:com_google_protobuf_protobuf_java",
+    "//lib:io_grpc_grpc_core_context",
+    "//lib:io_grpc_grpc_netty",
+    "//lib:io_grpc_grpc_stub",
     "//core/store/serializers:onos-core-serializers",
     "//protocols/gnmi/stub:onos-protocols-gnmi-stub",
     "//protocols/gnmi/api:onos-protocols-gnmi-api",
diff --git a/apps/openstacktelemetry/BUILD b/apps/openstacktelemetry/BUILD
index 8e5007a..33b9813 100644
--- a/apps/openstacktelemetry/BUILD
+++ b/apps/openstacktelemetry/BUILD
@@ -16,13 +16,13 @@
     "@simpleclient_hotspot//jar",
     "@simpleclient_servlet//jar",
     # gRPC dependencies (with patched core)
-    "//protocols/grpc:grpc-core",
-    "//protocols/grpc:grpc-stub",
-    "//protocols/grpc:grpc-netty",
-    "//protocols/grpc:grpc-auth",
-    "//protocols/grpc:grpc-protobuf",
-    "//protocols/grpc:grpc-protobuf-lite",
-    "//protocols/grpc: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",
diff --git a/apps/openstacktelemetry/app/BUILD b/apps/openstacktelemetry/app/BUILD
index e4422bc..ecfb34d 100644
--- a/apps/openstacktelemetry/app/BUILD
+++ b/apps/openstacktelemetry/app/BUILD
@@ -12,8 +12,8 @@
     "@jetty_util//jar",
     "@jetty_websocket//jar",
     "@servlet_api//jar",
-    "@io_grpc_grpc_java//core",
-    "@io_grpc_grpc_java//protobuf-lite",
+    "//lib:io_grpc_grpc_core_context",
+    "//lib:io_grpc_grpc_protobuf_lite",
     "//core/store/serializers:onos-core-serializers",
     "//apps/openstacknode/api:onos-apps-openstacknode-api",
     "//apps/openstacknetworking/api:onos-apps-openstacknetworking-api",
diff --git a/drivers/bmv2/BUILD b/drivers/bmv2/BUILD
index 5cf6f45..9478b50 100644
--- a/drivers/bmv2/BUILD
+++ b/drivers/bmv2/BUILD
@@ -4,8 +4,8 @@
     "//pipelines/basic:onos-pipelines-basic",
     "//protocols/p4runtime/api:onos-protocols-p4runtime-api",
     "//protocols/p4runtime/model:onos-protocols-p4runtime-model",
-    "@io_grpc_grpc_java//core",
-    "@io_grpc_grpc_java//netty",
+    "//lib:io_grpc_grpc_core_context",
+    "//lib:io_grpc_grpc_netty",
     "@minimal_json//jar",
     # "//protocols/bmv2/thrift-api:onos-protocols-bmv2-thrift-api",
     #"//lib:libthrift",
diff --git a/drivers/gnmi/BUILD b/drivers/gnmi/BUILD
index f01a9f3..f2c33d0 100644
--- a/drivers/gnmi/BUILD
+++ b/drivers/gnmi/BUILD
@@ -1,8 +1,8 @@
 COMPILE_DEPS = CORE_DEPS + KRYO + [
-    "@com_google_protobuf//:protobuf_java",
-    "@io_grpc_grpc_java//core",
-    "@io_grpc_grpc_java//netty",
-    "@io_grpc_grpc_java//stub",
+    "//lib:com_google_protobuf_protobuf_java",
+    "//lib:io_grpc_grpc_core_context",
+    "//lib:io_grpc_grpc_netty",
+    "//lib:io_grpc_grpc_stub",
     "//core/store/serializers:onos-core-serializers",
     "//protocols/gnmi/stub:onos-protocols-gnmi-stub",
     "//protocols/gnmi/api:onos-protocols-gnmi-api",
diff --git a/drivers/gnoi/BUILD b/drivers/gnoi/BUILD
index b5355a9..122c961 100644
--- a/drivers/gnoi/BUILD
+++ b/drivers/gnoi/BUILD
@@ -1,8 +1,8 @@
 COMPILE_DEPS = CORE_DEPS + KRYO + [
-    "@com_google_protobuf//:protobuf_java",
-    "@io_grpc_grpc_java//core",
-    "@io_grpc_grpc_java//netty",
-    "@io_grpc_grpc_java//stub",
+    "//lib:com_google_protobuf_protobuf_java",
+    "//lib:io_grpc_grpc_core_context",
+    "//lib:io_grpc_grpc_netty",
+    "//lib:io_grpc_grpc_stub",
     "//protocols/gnoi/stub:onos-protocols-gnoi-stub",
     "//protocols/gnoi/api:onos-protocols-gnoi-api",
     "//protocols/grpc/api:onos-protocols-grpc-api",
diff --git a/drivers/p4runtime/BUILD b/drivers/p4runtime/BUILD
index f97dbd7..23c6e9e 100644
--- a/drivers/p4runtime/BUILD
+++ b/drivers/p4runtime/BUILD
@@ -3,7 +3,7 @@
     "//protocols/grpc/api:onos-protocols-grpc-api",
     "//protocols/grpc/utils:onos-protocols-grpc-utils",
     "//protocols/p4runtime/api:onos-protocols-p4runtime-api",
-    "@io_grpc_grpc_java//core",
+    "//lib:io_grpc_grpc_core_context",
 ]
 
 BUNDLES = [
diff --git a/drivers/stratum/BUILD b/drivers/stratum/BUILD
index a87c97e..91b055c 100644
--- a/drivers/stratum/BUILD
+++ b/drivers/stratum/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + KRYO + JACKSON + [
-    "@io_grpc_grpc_java//core",
+    "//lib:io_grpc_grpc_core_context",
     "//drivers/p4runtime:onos-drivers-p4runtime",
     "//drivers/gnmi:onos-drivers-gnmi",
     "//drivers/gnoi:onos-drivers-gnoi",
diff --git a/lib/BUILD b/lib/BUILD
new file mode 100644
index 0000000..52c4ea6
--- /dev/null
+++ b/lib/BUILD
@@ -0,0 +1,66 @@
+load("//tools/build/bazel:osgi_java_library.bzl", "wrapped_osgi_jar")
+
+# Wrap protobuf and grpc-related JARs in OSGi-compatible ones, since the
+# original ones are built with Bazel and NOT imported via mvn.
+
+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 = "io_grpc_grpc_core_context",
+    generate_pom = True,
+    jar = "@io_grpc_grpc_java//core",
+    visibility = ["//visibility:public"],
+    deps = [],
+)
+
+wrapped_osgi_jar(
+    name = "io_grpc_grpc_stub",
+    generate_pom = True,
+    jar = "@io_grpc_grpc_java//stub",
+    visibility = ["//visibility:public"],
+    deps = [],
+)
+
+wrapped_osgi_jar(
+    name = "io_grpc_grpc_netty",
+    generate_pom = True,
+    jar = "@io_grpc_grpc_java//netty",
+    visibility = ["//visibility:public"],
+    deps = [],
+)
+
+wrapped_osgi_jar(
+    name = "io_grpc_grpc_auth",
+    generate_pom = True,
+    jar = "@io_grpc_grpc_java//auth",
+    visibility = ["//visibility:public"],
+    deps = [],
+)
+
+wrapped_osgi_jar(
+    name = "io_grpc_grpc_protobuf",
+    generate_pom = True,
+    jar = "@io_grpc_grpc_java//protobuf",
+    visibility = ["//visibility:public"],
+    deps = [],
+)
+
+wrapped_osgi_jar(
+    name = "io_grpc_grpc_protobuf_lite",
+    generate_pom = True,
+    jar = "@io_grpc_grpc_java//protobuf-lite",
+    visibility = ["//visibility:public"],
+    deps = [],
+)
+
+wrapped_osgi_jar(
+    name = "com_google_protobuf_protobuf_java",
+    generate_pom = True,
+    jar = "@com_google_protobuf//:protobuf_java",
+    visibility = ["//visibility:public"],
+    deps = [],
+)
diff --git a/protocols/gnmi/ctl/BUILD b/protocols/gnmi/ctl/BUILD
index e12a8ce..482a37f 100644
--- a/protocols/gnmi/ctl/BUILD
+++ b/protocols/gnmi/ctl/BUILD
@@ -3,18 +3,18 @@
     "//protocols/gnmi/stub:onos-protocols-gnmi-stub",
     "//protocols/grpc/api:onos-protocols-grpc-api",
     "//protocols/grpc/ctl:onos-protocols-grpc-ctl",
-    "//protocols/grpc:grpc-core",
-    "@com_google_protobuf//:protobuf_java",
-    "@io_grpc_grpc_java//netty",
-    "@io_grpc_grpc_java//protobuf-lite",
-    "@io_grpc_grpc_java//stub",
+    "//lib:io_grpc_grpc_core_context",
+    "//lib:com_google_protobuf_protobuf_java",
+    "//lib:io_grpc_grpc_netty",
+    "//lib:io_grpc_grpc_protobuf_lite",
+    "//lib:io_grpc_grpc_stub",
     "@com_google_api_grpc_proto_google_common_protos//jar",
 ]
 
 TEST_DEPS = TEST + [
     "@minimal_json//jar",
-    "@io_grpc_grpc_java//core:inprocess",
-    "@io_grpc_grpc_java//protobuf-lite",
+    "//lib:io_grpc_grpc_core_context",
+    "//lib:io_grpc_grpc_protobuf_lite",
 ]
 
 osgi_jar_with_tests(
diff --git a/protocols/gnoi/ctl/BUILD b/protocols/gnoi/ctl/BUILD
index 9fdb3a8..84322ba 100644
--- a/protocols/gnoi/ctl/BUILD
+++ b/protocols/gnoi/ctl/BUILD
@@ -3,18 +3,18 @@
     "//protocols/gnoi/stub:onos-protocols-gnoi-stub",
     "//protocols/grpc/api:onos-protocols-grpc-api",
     "//protocols/grpc/ctl:onos-protocols-grpc-ctl",
-    "//protocols/grpc:grpc-core",
-    "@com_google_protobuf//:protobuf_java",
-    "@io_grpc_grpc_java//netty",
-    "@io_grpc_grpc_java//protobuf-lite",
-    "@io_grpc_grpc_java//stub",
+    "//lib:io_grpc_grpc_core_context",
+    "//lib:com_google_protobuf_protobuf_java",
+    "//lib:io_grpc_grpc_netty",
+    "//lib:io_grpc_grpc_protobuf_lite",
+    "//lib:io_grpc_grpc_stub",
     "@com_google_api_grpc_proto_google_common_protos//jar",
 ]
 
 TEST_DEPS = TEST + [
     "@minimal_json//jar",
-    "@io_grpc_grpc_java//core:inprocess",
-    "@io_grpc_grpc_java//protobuf-lite",
+    "//lib:io_grpc_grpc_core_context",
+    "//lib:io_grpc_grpc_protobuf_lite",
 ]
 
 osgi_jar_with_tests(
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(
diff --git a/protocols/p4runtime/api/BUILD b/protocols/p4runtime/api/BUILD
index 2fb15ba..47a4dd2 100644
--- a/protocols/p4runtime/api/BUILD
+++ b/protocols/p4runtime/api/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",
 ]
 
 TEST_DEPS = TEST + [
diff --git a/protocols/p4runtime/ctl/BUILD b/protocols/p4runtime/ctl/BUILD
index 31cd184..628d162 100644
--- a/protocols/p4runtime/ctl/BUILD
+++ b/protocols/p4runtime/ctl/BUILD
@@ -4,18 +4,18 @@
     "//protocols/grpc/ctl:onos-protocols-grpc-ctl",
     "//protocols/p4runtime/api:onos-protocols-p4runtime-api",
     "//protocols/p4runtime/proto:onos-protocols-p4runtime-proto",
-    "@com_google_protobuf//:protobuf_java",
-    "//protocols/grpc:grpc-core",
-    "@io_grpc_grpc_java//netty",
-    "@io_grpc_grpc_java//protobuf-lite",
-    "@io_grpc_grpc_java//stub",
+    "//lib:com_google_protobuf_protobuf_java",
+    "//lib:io_grpc_grpc_core_context",
+    "//lib:io_grpc_grpc_netty",
+    "//lib:io_grpc_grpc_protobuf_lite",
+    "//lib:io_grpc_grpc_stub",
     "@com_google_api_grpc_proto_google_common_protos//jar",
 ]
 
 TEST_DEPS = TEST + [
     "@minimal_json//jar",
-    "@io_grpc_grpc_java//core:inprocess",
-    "@io_grpc_grpc_java//protobuf-lite",
+    "//lib:io_grpc_grpc_core_context",
+    "//lib:io_grpc_grpc_protobuf_lite",
 ]
 
 osgi_jar_with_tests(
diff --git a/protocols/p4runtime/model/BUILD b/protocols/p4runtime/model/BUILD
index 619d8ee..9e36b6d 100644
--- a/protocols/p4runtime/model/BUILD
+++ b/protocols/p4runtime/model/BUILD
@@ -1,6 +1,6 @@
 COMPILE_DEPS = CORE_DEPS + [
     "//protocols/p4runtime/proto:onos-protocols-p4runtime-proto",
-    "@com_google_protobuf//:protobuf_java",
+    "//lib:com_google_protobuf_protobuf_java",
 ]
 
 osgi_jar_with_tests(
diff --git a/providers/general/device/BUILD b/providers/general/device/BUILD
index 40957b1..d8d3929 100644
--- a/providers/general/device/BUILD
+++ b/providers/general/device/BUILD
@@ -1,7 +1,7 @@
 COMPILE_DEPS = CORE_DEPS + JACKSON + [
     "//protocols/gnmi/stub:onos-protocols-gnmi-stub",
     "//protocols/gnmi/api:onos-protocols-gnmi-api",
-    "@com_google_protobuf//:protobuf_java",
+    "//lib:com_google_protobuf_protobuf_java",
     "//protocols/grpc/api:onos-protocols-grpc-api",
 ]
 
diff --git a/tools/build/bazel/grpc_workspace.bzl b/tools/build/bazel/grpc_workspace.bzl
index 93703b8..3c81c9a 100644
--- a/tools/build/bazel/grpc_workspace.bzl
+++ b/tools/build/bazel/grpc_workspace.bzl
@@ -1,7 +1,6 @@
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-load("//tools/build/bazel:variables.bzl", "GRPC_JAVA_VERSION")
 
-GRPC_VER = "1.18.0"
+GRPC_JAVA_VERSION = "1.18.0"
 GRPC_SHA = "979cd1873c0f3aefa25f3d20336c023ce34471203bf2d954ad9e3158fc55c16b"
 
 GAPIS_COMMIT = "37cc0e5acae50ee91f00827a7010c3b07dfa5311"
diff --git a/tools/build/bazel/osgi_java_library.bzl b/tools/build/bazel/osgi_java_library.bzl
index c6fd523..beba414 100644
--- a/tools/build/bazel/osgi_java_library.bzl
+++ b/tools/build/bazel/osgi_java_library.bzl
@@ -364,7 +364,8 @@
         version = ONOS_VERSION,
         group = "org.onosproject",
         import_packages = "*",
-        visibility = ["//visibility:private"]):
+        visibility = ["//visibility:private"],
+        generate_pom = False):
     _bnd(
         name = name,
         source = jar,
@@ -376,6 +377,14 @@
         web_xml = None,
     )
 
+    if generate_pom:
+        pom_file(
+            name = name + "-pom",
+            artifact = name,
+            deps = deps,
+            visibility = visibility,
+        )
+
 """
     Creates an OSGI jar and test jar file from a set of source and test files.
     See osgi_jar() for a description of shared parameters.
@@ -698,7 +707,7 @@
         ":%s-proto-srcjar" % name,
     ]
     base_deps = [
-        "@com_google_protobuf//:protobuf_java",
+        "//lib:com_google_protobuf_protobuf_java",
     ]
     if grpc_proto_lib != None:
         java_grpc_library(
@@ -711,9 +720,9 @@
         )
         base_deps.extend([
             "@com_google_guava_guava//jar",
-            "@io_grpc_grpc_java//core",
-            "@io_grpc_grpc_java//stub",
-            "@io_grpc_grpc_java//protobuf",
+            "//lib:io_grpc_grpc_core_context",
+            "//lib:io_grpc_grpc_stub",
+            "//lib:io_grpc_grpc_protobuf",
         ])
     osgi_jar(
         name = name,
diff --git a/tools/build/bazel/protobuf_workspace.bzl b/tools/build/bazel/protobuf_workspace.bzl
index bf7e62b..e67ba91 100644
--- a/tools/build/bazel/protobuf_workspace.bzl
+++ b/tools/build/bazel/protobuf_workspace.bzl
@@ -1,6 +1,6 @@
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-load("//tools/build/bazel:variables.bzl", "PROTOBUF_VERSION")
 
+PROTOBUF_VERSION = "3.6.1.3"
 SHA = "9510dd2afc29e7245e9e884336f848c8a6600a14ae726adb6befdb4f786f0be2"
 
 def generate_protobuf():
diff --git a/tools/build/bazel/variables.bzl b/tools/build/bazel/variables.bzl
index 90a7479..943c1d0 100644
--- a/tools/build/bazel/variables.bzl
+++ b/tools/build/bazel/variables.bzl
@@ -4,6 +4,3 @@
 ONOS_ORIGIN = "ONOS Community"
 APP_PREFIX = ONOS_GROUP_ID + "."
 DEFAULT_APP_CATEGORY = "Utility"
-
-GRPC_JAVA_VERSION = "1.18.0"
-PROTOBUF_VERSION = "3.6.1.3"
diff --git a/tools/build/onos-publish-catalog b/tools/build/onos-publish-catalog
index 874744a..3864b10 100755
--- a/tools/build/onos-publish-catalog
+++ b/tools/build/onos-publish-catalog
@@ -33,6 +33,14 @@
     egrep -v '(\#|build/conf)' tools/build/publish-target-list
 }
 
+function sourceJars {
+    egrep -v '(\#|lib\:|p4runtime/proto|build/conf)' tools/build/publish-target-list
+}
+
+function javadocJars {
+    egrep -v '(\#|lib\:|p4runtime/proto|build/conf)' tools/build/publish-target-list
+}
+
 function testJars {
     egrep -v '(\#|build/conf)' tools/build/publish-test-target-list
 }
@@ -46,9 +54,9 @@
 [ $libsOnly = true ] && exit 0
 
 echo "Cataloging source jars..."
-writeCatalog $(jars | sed 's/$/-sources/')
+writeCatalog $(sourceJars | sed 's/$/-sources/')
 echo "Cataloging javadoc jars..."
-writeCatalog $(jars | sed 's/$/-javadoc/')
+writeCatalog $(javadocJars | sed 's/$/-javadoc/')
 echo "Cataloging pom files..."
 writeCatalog $(jars | sed 's/$/-pom/')
 
diff --git a/tools/build/publish-target-list b/tools/build/publish-target-list
index 41b637a..4cf5ac5 100644
--- a/tools/build/publish-target-list
+++ b/tools/build/publish-target-list
@@ -20,6 +20,7 @@
     //protocols/grpc/api:onos-protocols-grpc-api
     //protocols/p4runtime/api:onos-protocols-p4runtime-api
     //protocols/p4runtime/model:onos-protocols-p4runtime-model
+    //protocols/p4runtime/proto:onos-protocols-p4runtime-proto
     //protocols/grpc/utils:onos-protocols-grpc-utils
     //protocols/gnmi/api:onos-protocols-gnmi-api
     //protocols/gnoi/api:onos-protocols-gnoi-api
@@ -45,3 +46,7 @@
     //utils/osgi:onlab-osgi
     //utils/rest:onlab-rest
     //web/api:onos-rest
+    //lib:com_google_protobuf_protobuf_java
+    //lib:io_grpc_grpc_core_context
+    //lib:io_grpc_grpc_stub
+    //lib:io_grpc_grpc_protobuf