Allow building third-party apps based on gRPC

By publishing the repackaged grpc and protobuf artifacts

Change-Id: Ib3af7dba4f64948132aa70be31922de61d6f6ab2
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 9eb4b1d..acea2a9 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