[WIP] Attempt at building grpc and p4runtime protocols with Bazel

STILL NOT WORKING AT RUNTIME

Change-Id: I1f9e60b12a12e09edad2a714ec2921a4f71c6d35
diff --git a/protocols/bgp/api/BUCK b/protocols/bgp/api/BUCK
index e4aaf3e..37d94b0 100644
--- a/protocols/bgp/api/BUCK
+++ b/protocols/bgp/api/BUCK
@@ -2,7 +2,7 @@
     '//lib:CORE_DEPS',
     '//protocols/bgp/bgpio:onos-protocols-bgp-bgpio',
     '//core/api:onos-api',
-    '//lib:netty',
+    '//lib:io_netty_netty',
 ]
 
 osgi_jar_with_tests (
diff --git a/protocols/bgp/api/BUILD b/protocols/bgp/api/BUILD
index 7568aba..dac6528 100644
--- a/protocols/bgp/api/BUILD
+++ b/protocols/bgp/api/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + [
-    "@netty//jar",
+    "@io_netty_netty//jar",
     "//protocols/bgp/bgpio:onos-protocols-bgp-bgpio",
 ]
 
diff --git a/protocols/bgp/bgpio/BUCK b/protocols/bgp/bgpio/BUCK
index 0656504..32d5f4d 100644
--- a/protocols/bgp/bgpio/BUCK
+++ b/protocols/bgp/bgpio/BUCK
@@ -3,7 +3,7 @@
     '//lib:COMPILE',
     '//lib:NETTY',
     '//core/api:onos-api',
-    '//lib:netty',
+    '//lib:io_netty_netty',
 ]
 
 osgi_jar_with_tests (
diff --git a/protocols/bgp/bgpio/BUILD b/protocols/bgp/bgpio/BUILD
index a375113..db96180 100644
--- a/protocols/bgp/bgpio/BUILD
+++ b/protocols/bgp/bgpio/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + [
-    "@netty//jar",
+    "@io_netty_netty//jar",
 ]
 
 osgi_jar_with_tests(
diff --git a/protocols/bgp/ctl/BUCK b/protocols/bgp/ctl/BUCK
index 5d4ac76..3568c2e 100644
--- a/protocols/bgp/ctl/BUCK
+++ b/protocols/bgp/ctl/BUCK
@@ -6,8 +6,8 @@
     '//lib:javax.ws.rs-api',
     '//protocols/bgp/api:onos-protocols-bgp-api',
     '//protocols/bgp/bgpio:onos-protocols-bgp-bgpio',
-    '//lib:netty-common',
-    '//lib:netty',
+    '//lib:io_netty_netty_common',
+    '//lib:io_netty_netty',
     '//lib:org.osgi.compendium',
     '//lib:org.apache.felix.scr.annotations',
 ]
diff --git a/protocols/bgp/ctl/BUILD b/protocols/bgp/ctl/BUILD
index 41ab47e..a7cf7ad 100644
--- a/protocols/bgp/ctl/BUILD
+++ b/protocols/bgp/ctl/BUILD
@@ -3,8 +3,8 @@
     "@httpclient_osgi//jar",
     "@httpcore_osgi//jar",
     "@javax_ws_rs_api//jar",
-    "@netty_common//jar",
-    "@netty//jar",
+    "@io_netty_netty_common//jar",
+    "@io_netty_netty//jar",
     "//protocols/bgp/api:onos-protocols-bgp-api",
     "//protocols/bgp/bgpio:onos-protocols-bgp-bgpio",
 ]
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/Controller.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/Controller.java
index acd1c7b..04c1c1d 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/Controller.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/Controller.java
@@ -221,7 +221,7 @@
      */
     public void start() {
         log.info("Started");
-        if (!PlatformDependent.isWindows() && !PlatformDependent.isRoot()) {
+        if (!PlatformDependent.isWindows() && !PlatformDependent.maybeSuperUser()) {
             portNumber = BGP_PRIVILEGED_PORT;
         } else {
             portNumber = BGP_PORT_NUM;
diff --git a/protocols/grpc/BUCK b/protocols/grpc/BUCK
index e5e65e1..093ea7d 100644
--- a/protocols/grpc/BUCK
+++ b/protocols/grpc/BUCK
@@ -16,16 +16,16 @@
     '//lib:protobuf-java-3.2.0',
     # Lazily adding all netty-related packages.
     # Some of them might not be necessary.
-    '//lib:netty',
-    '//lib:netty-buffer',
-    '//lib:netty-codec',
-    '//lib:netty-codec-http',
-    '//lib:netty-codec-http2',
-    '//lib:netty-common',
-    '//lib:netty-handler',
-    '//lib:netty-transport',
-    '//lib:netty-transport-native-epoll',
-    '//lib:netty-resolver',
+    '//lib:io_netty_netty',
+    '//lib:io_netty_netty_buffer',
+    '//lib:io_netty_netty_codec',
+    '//lib:io_netty_netty_codec-http',
+    '//lib:io_netty_netty_codec-http2',
+    '//lib:io_netty_netty_common',
+    '//lib:io_netty_netty_handler',
+    '//lib:io_netty_netty_transport',
+    '//lib:io_netty_netty_transport-native-epoll',
+    '//lib:io_netty_netty_resolver',
 ]
 
 onos_app (
diff --git a/protocols/grpc/BUILD b/protocols/grpc/BUILD
new file mode 100644
index 0000000..53c351f
--- /dev/null
+++ b/protocols/grpc/BUILD
@@ -0,0 +1,36 @@
+
+BUNDLES = [
+    "//protocols/grpc/proto:dummy_java_grpc",
+    "//protocols/grpc/proto:dummy_java_proto",
+    "//protocols/grpc/api:onos-protocols-grpc-api",
+    "//protocols/grpc/ctl:onos-protocols-grpc-ctl",
+    # gRPC dependencies
+    "@io_grpc_grpc_java//core",
+    "@io_grpc_grpc_java//stub",
+    "@io_grpc_grpc_java//netty",
+    "@io_grpc_grpc_java//auth",
+    "@io_grpc_grpc_java//protobuf",
+    "@io_grpc_grpc_java//protobuf-lite",
+    "@com_google_protobuf//:protobuf_java",
+    # 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 (
+    app_name = "org.onosproject.protocols.grpc",
+    title = "RPC Protocol Subsystem",
+    category = "rotocol",
+    url = "ttp://onosproject.org",
+    description = "Exposes APIs to operate with gRPC channels",
+    included_bundles = BUNDLES,
+)
diff --git a/protocols/grpc/api/BUILD b/protocols/grpc/api/BUILD
new file mode 100644
index 0000000..f7fee65
--- /dev/null
+++ b/protocols/grpc/api/BUILD
@@ -0,0 +1,3 @@
+osgi_jar (
+    deps = CORE_DEPS + ["@io_grpc_grpc_java//core"],
+)
diff --git a/protocols/grpc/ctl/BUILD b/protocols/grpc/ctl/BUILD
new file mode 100644
index 0000000..2d199ef
--- /dev/null
+++ b/protocols/grpc/ctl/BUILD
@@ -0,0 +1,8 @@
+osgi_jar (
+    deps = CORE_DEPS + [
+        "//protocols/grpc/api:onos-protocols-grpc-api",
+        "//protocols/grpc/proto:dummy_java_grpc",
+        "//protocols/grpc/proto:dummy_java_proto",
+        "@io_grpc_grpc_java//core"
+    ],
+)
diff --git a/protocols/grpc/proto/BUILD b/protocols/grpc/proto/BUILD
new file mode 100644
index 0000000..bebc0ef
--- /dev/null
+++ b/protocols/grpc/proto/BUILD
@@ -0,0 +1,39 @@
+load("//tools/build/bazel:osgi_java_library.bzl", "wrapped_osgi_jar")
+load("@io_grpc_grpc_java//:java_grpc_library.bzl", "java_grpc_library")
+
+wrapped_osgi_jar(
+    name = "dummy_java_grpc",
+    jar = ":dummy_java_grpc_native",
+    deps = [
+        "@io_grpc_grpc_java//stub",
+        "@io_grpc_grpc_java//core",
+        "@io_grpc_grpc_java//protobuf"
+    ],
+    visibility = ["//visibility:public"],
+)
+
+wrapped_osgi_jar(
+    name = "dummy_java_proto",
+    jar = ":dummy_java_proto_native",
+    deps = [
+        "@com_google_protobuf//:protobuf_java",
+    ],
+    visibility = ["//visibility:public"],
+)
+
+java_proto_library(
+    name = "dummy_java_proto_native",
+    deps = [":dummy_proto"],
+    visibility = ["//visibility:public"],
+)
+
+java_grpc_library(
+    name = "dummy_java_grpc_native",
+    srcs = [":dummy_proto"],
+    deps = [":dummy_java_proto_native"],
+)
+
+proto_library(
+    name = "dummy_proto",
+    srcs = ["dummy.proto"],
+)
diff --git a/protocols/isis/api/BUCK b/protocols/isis/api/BUCK
index 55ca0d0..75c833b 100644
--- a/protocols/isis/api/BUCK
+++ b/protocols/isis/api/BUCK
@@ -2,7 +2,7 @@
     '//lib:CORE_DEPS',
     '//lib:NETTY',
     '//lib:JACKSON',
-    '//lib:netty',
+    '//lib:io_netty_netty',
 ]
 
 osgi_jar_with_tests (
diff --git a/protocols/isis/api/BUILD b/protocols/isis/api/BUILD
index e09f7da..9e01912 100644
--- a/protocols/isis/api/BUILD
+++ b/protocols/isis/api/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
-    "@netty//jar",
+    "@io_netty_netty//jar",
 ]
 
 osgi_jar_with_tests(
diff --git a/protocols/isis/ctl/BUCK b/protocols/isis/ctl/BUCK
index f99d235..1ab0b4b 100644
--- a/protocols/isis/ctl/BUCK
+++ b/protocols/isis/ctl/BUCK
@@ -4,7 +4,7 @@
     '//lib:JACKSON',
     '//protocols/isis/api:onos-protocols-isis-api',
     '//protocols/isis/isisio:onos-protocols-isis-isisio',
-    '//lib:netty',
+    '//lib:io_netty_netty',
 ]
 
 osgi_jar_with_tests (
diff --git a/protocols/isis/ctl/BUILD b/protocols/isis/ctl/BUILD
index a74b52a..950f043 100644
--- a/protocols/isis/ctl/BUILD
+++ b/protocols/isis/ctl/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
-    "@netty//jar",
+    "@io_netty_netty//jar",
     "//protocols/isis/api:onos-protocols-isis-api",
     "//protocols/isis/isisio:onos-protocols-isis-isisio",
 ]
diff --git a/protocols/isis/isisio/BUCK b/protocols/isis/isisio/BUCK
index 4484db7..abcd593 100644
--- a/protocols/isis/isisio/BUCK
+++ b/protocols/isis/isisio/BUCK
@@ -2,7 +2,7 @@
     '//lib:CORE_DEPS',
     '//lib:NETTY',
     '//protocols/isis/api:onos-protocols-isis-api',
-    '//lib:netty',
+    '//lib:io_netty_netty',
 ]
 
 osgi_jar_with_tests (
diff --git a/protocols/isis/isisio/BUILD b/protocols/isis/isisio/BUILD
index 08bce5d..ad966c4 100644
--- a/protocols/isis/isisio/BUILD
+++ b/protocols/isis/isisio/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + [
-    "@netty//jar",
+    "@io_netty_netty//jar",
     "//protocols/isis/api:onos-protocols-isis-api",
 ]
 
diff --git a/protocols/lisp/api/BUCK b/protocols/lisp/api/BUCK
index f88d20c..a182f2b 100644
--- a/protocols/lisp/api/BUCK
+++ b/protocols/lisp/api/BUCK
@@ -1,7 +1,7 @@
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//lib:NETTY',
-    '//lib:netty-transport',
+    '//lib:io_netty_netty_transport',
     '//protocols/lisp/msg:onos-protocols-lisp-msg',
     '//apps/mappingmanagement/api:onos-apps-mappingmanagement-api',
 ]
diff --git a/protocols/lisp/api/BUILD b/protocols/lisp/api/BUILD
index 72ff459..6ab1d56 100644
--- a/protocols/lisp/api/BUILD
+++ b/protocols/lisp/api/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + [
-    "@netty_transport//jar",
+    "@io_netty_netty_transport//jar",
     "//protocols/lisp/msg:onos-protocols-lisp-msg",
     "//apps/mappingmanagement/api:onos-apps-mappingmanagement-api",
 ]
diff --git a/protocols/lisp/ctl/BUCK b/protocols/lisp/ctl/BUCK
index ea114b5..25764e7 100644
--- a/protocols/lisp/ctl/BUCK
+++ b/protocols/lisp/ctl/BUCK
@@ -3,12 +3,12 @@
     '//lib:NETTY',
     '//protocols/lisp/api:onos-protocols-lisp-api',
     '//protocols/lisp/msg:onos-protocols-lisp-msg',
-    '//lib:netty-buffer',
-    '//lib:netty-codec',
-    '//lib:netty-transport',
-    '//lib:netty-transport-native-epoll',
-    '//lib:netty-handler',
-    '//lib:netty-resolver',
+    '//lib:io_netty_netty_buffer',
+    '//lib:io_netty_netty_codec',
+    '//lib:io_netty_netty_transport',
+    '//lib:io_netty_netty_transport-native-epoll',
+    '//lib:io_netty_netty_handler',
+    '//lib:io_netty_netty_resolver',
     '//lib:concurrent-trees',
 ]
 
diff --git a/protocols/lisp/ctl/BUILD b/protocols/lisp/ctl/BUILD
index c16ccd8..834a704 100644
--- a/protocols/lisp/ctl/BUILD
+++ b/protocols/lisp/ctl/BUILD
@@ -1,9 +1,9 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + [
-    "@netty_codec//jar",
-    "@netty_transport//jar",
-    "@netty_transport_native_epoll//jar",
-    "@netty_handler//jar",
-    "@netty_resolver//jar",
+    "@io_netty_netty_codec//jar",
+    "@io_netty_netty_transport//jar",
+    "@io_netty_netty_transport_native_epoll//jar",
+    "@io_netty_netty_handler//jar",
+    "@io_netty_netty_resolver//jar",
     "@concurrent_trees//jar",
     "//protocols/lisp/api:onos-protocols-lisp-api",
     "//protocols/lisp/msg:onos-protocols-lisp-msg",
diff --git a/protocols/lisp/msg/BUCK b/protocols/lisp/msg/BUCK
index dbf3d0d..2e2b8a7 100644
--- a/protocols/lisp/msg/BUCK
+++ b/protocols/lisp/msg/BUCK
@@ -1,7 +1,7 @@
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//lib:NETTY',
-    '//lib:netty-buffer'
+    '//lib:io_netty_netty_buffer'
 ]
 
 TEST_DEPS = [
diff --git a/protocols/openflow/api/BUCK b/protocols/openflow/api/BUCK
index 266a1fc..41fc729 100644
--- a/protocols/openflow/api/BUCK
+++ b/protocols/openflow/api/BUCK
@@ -2,7 +2,7 @@
     '//lib:CORE_DEPS',
     '//lib:NETTY',
     '//lib:openflowj',
-    '//lib:netty-transport',
+    '//lib:io_netty_netty_transport',
 ]
 
 TEST_DEPS = [
diff --git a/protocols/openflow/api/BUILD b/protocols/openflow/api/BUILD
index a7df405..3232c98 100644
--- a/protocols/openflow/api/BUILD
+++ b/protocols/openflow/api/BUILD
@@ -3,7 +3,7 @@
     "//incubator/api:onos-incubator-api",
     "//core/common:onos-core-common",
     "@openflowj//jar",
-    "@netty_transport//jar",
+    "@io_netty_netty_transport//jar",
 ]
 
 TEST_DEPS = TEST + [
diff --git a/protocols/openflow/ctl/BUCK b/protocols/openflow/ctl/BUCK
index 9b68ba9..684fb64 100644
--- a/protocols/openflow/ctl/BUCK
+++ b/protocols/openflow/ctl/BUCK
@@ -1,15 +1,15 @@
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
-    '//lib:openflowj',
-    '//protocols/openflow/api:onos-protocols-openflow-api',
-    '//lib:NETTY',
-    '//lib:netty-buffer',
-    '//lib:netty-codec',
-    '//lib:netty-common',
-    '//lib:netty-handler',
-    '//lib:netty-transport',
-    '//lib:netty-transport-native-epoll',
     '//lib:JACKSON',
+    '//lib:openflowj',
+    '//lib:io_netty_netty_buffer',
+    '//lib:io_netty_netty_common',
+    '//lib:io_netty_netty_codec',
+    '//lib:io_netty_netty_handler',
+    '//lib:io_netty_netty_transport',
+    '//lib:io_netty_netty_transport_native_unix_common',
+    '//lib:io_netty_netty_transport-native-epoll',
+    '//protocols/openflow/api:onos-protocols-openflow-api',
 ]
 
 TEST_DEPS = [
diff --git a/protocols/openflow/ctl/BUILD b/protocols/openflow/ctl/BUILD
index 3bf8b7f..b469e1c 100644
--- a/protocols/openflow/ctl/BUILD
+++ b/protocols/openflow/ctl/BUILD
@@ -1,9 +1,10 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
     "@openflowj//jar",
-    "@netty_codec//jar",
-    "@netty_handler//jar",
-    "@netty_transport//jar",
-    "@netty_transport_native_epoll//jar",
+    "@io_netty_netty_codec//jar",
+    "@io_netty_netty_handler//jar",
+    "@io_netty_netty_transport//jar",
+    "@io_netty_netty_transport_native_epoll//jar",
+    "@io_netty_netty_transport_native_unix_common//jar",
     "//protocols/openflow/api:onos-protocols-openflow-api",
 ]
 
diff --git a/protocols/ospf/api/BUCK b/protocols/ospf/api/BUCK
index 55ca0d0..75c833b 100644
--- a/protocols/ospf/api/BUCK
+++ b/protocols/ospf/api/BUCK
@@ -2,7 +2,7 @@
     '//lib:CORE_DEPS',
     '//lib:NETTY',
     '//lib:JACKSON',
-    '//lib:netty',
+    '//lib:io_netty_netty',
 ]
 
 osgi_jar_with_tests (
diff --git a/protocols/ospf/api/BUILD b/protocols/ospf/api/BUILD
index e09f7da..9e01912 100644
--- a/protocols/ospf/api/BUILD
+++ b/protocols/ospf/api/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
-    "@netty//jar",
+    "@io_netty_netty//jar",
 ]
 
 osgi_jar_with_tests(
diff --git a/protocols/ospf/ctl/BUCK b/protocols/ospf/ctl/BUCK
index 24415cf..ec894cc 100644
--- a/protocols/ospf/ctl/BUCK
+++ b/protocols/ospf/ctl/BUCK
@@ -4,7 +4,7 @@
     '//lib:JACKSON',
     '//protocols/ospf/api:onos-protocols-ospf-api',
     '//protocols/ospf/protocol:onos-protocols-ospf-protocol',
-    '//lib:netty',
+    '//lib:io_netty_netty',
 ]
 
 osgi_jar_with_tests (
diff --git a/protocols/ospf/ctl/BUILD b/protocols/ospf/ctl/BUILD
index 40ce45b..de94b39 100644
--- a/protocols/ospf/ctl/BUILD
+++ b/protocols/ospf/ctl/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
-    "@netty//jar",
+    "@io_netty_netty//jar",
     "//protocols/ospf/api:onos-protocols-ospf-api",
     "//protocols/ospf/protocol:onos-protocols-ospf-protocol",
 ]
diff --git a/protocols/ospf/protocol/BUCK b/protocols/ospf/protocol/BUCK
index 38c51e2..46a8746 100644
--- a/protocols/ospf/protocol/BUCK
+++ b/protocols/ospf/protocol/BUCK
@@ -2,7 +2,7 @@
     '//lib:CORE_DEPS',
     '//lib:NETTY',
     '//protocols/ospf/api:onos-protocols-ospf-api',
-    '//lib:netty',
+    '//lib:io_netty_netty',
 ]
 
 osgi_jar_with_tests (
diff --git a/protocols/ospf/protocol/BUILD b/protocols/ospf/protocol/BUILD
index a4bfe42..6543146 100644
--- a/protocols/ospf/protocol/BUILD
+++ b/protocols/ospf/protocol/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + [
-    "@netty//jar",
+    "@io_netty_netty//jar",
     "//protocols/ospf/api:onos-protocols-ospf-api",
 ]
 
diff --git a/protocols/ovsdb/api/BUCK b/protocols/ovsdb/api/BUCK
index 0aff936..f9b5802 100644
--- a/protocols/ovsdb/api/BUCK
+++ b/protocols/ovsdb/api/BUCK
@@ -2,7 +2,7 @@
     '//lib:CORE_DEPS',
     '//lib:NETTY',
     '//lib:JACKSON',
-    '//lib:netty-transport',
+    '//lib:io_netty_netty_transport',
     '//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc',
 ]
 
diff --git a/protocols/ovsdb/api/BUILD b/protocols/ovsdb/api/BUILD
index f344b92..c570a5b 100644
--- a/protocols/ovsdb/api/BUILD
+++ b/protocols/ovsdb/api/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
-    "@netty_transport//jar",
+    "@io_netty_netty_transport//jar",
     "//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc",
 ]
 
diff --git a/protocols/ovsdb/ctl/BUCK b/protocols/ovsdb/ctl/BUCK
index c4ca55b..bd40154 100644
--- a/protocols/ovsdb/ctl/BUCK
+++ b/protocols/ovsdb/ctl/BUCK
@@ -2,10 +2,10 @@
     '//lib:CORE_DEPS',
     '//lib:NETTY',
     '//lib:JACKSON',
-    '//lib:netty-transport',
-    '//lib:netty-buffer',
-    '//lib:netty-codec',
-    '//lib:netty-handler',
+    '//lib:io_netty_netty_transport',
+    '//lib:io_netty_netty_buffer',
+    '//lib:io_netty_netty_codec',
+    '//lib:io_netty_netty_handler',
     '//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc',
     '//protocols/ovsdb/api:onos-protocols-ovsdb-api',
 ]
diff --git a/protocols/ovsdb/ctl/BUILD b/protocols/ovsdb/ctl/BUILD
index 79bc630..c61dbf3 100644
--- a/protocols/ovsdb/ctl/BUILD
+++ b/protocols/ovsdb/ctl/BUILD
@@ -1,7 +1,7 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
-    "@netty_transport//jar",
-    "@netty_codec//jar",
-    "@netty_handler//jar",
+    "@io_netty_netty_transport//jar",
+    "@io_netty_netty_codec//jar",
+    "@io_netty_netty_handler//jar",
     "//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc",
     "//protocols/ovsdb/api:onos-protocols-ovsdb-api",
 ]
diff --git a/protocols/ovsdb/rfc/BUCK b/protocols/ovsdb/rfc/BUCK
index 696bba1..47f8625 100644
--- a/protocols/ovsdb/rfc/BUCK
+++ b/protocols/ovsdb/rfc/BUCK
@@ -2,8 +2,8 @@
     '//lib:CORE_DEPS',
     '//lib:NETTY',
     '//lib:JACKSON',
-    '//lib:netty-buffer',
-    '//lib:netty-codec',
+    '//lib:io_netty_netty_buffer',
+    '//lib:io_netty_netty_codec',
 ]
 
 osgi_jar_with_tests (
diff --git a/protocols/ovsdb/rfc/BUILD b/protocols/ovsdb/rfc/BUILD
index f3558c7..e271647 100644
--- a/protocols/ovsdb/rfc/BUILD
+++ b/protocols/ovsdb/rfc/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
-    "@netty_codec//jar",
+    "@io_netty_netty_codec//jar",
 ]
 
 osgi_jar_with_tests(
diff --git a/protocols/p4runtime/BUILD b/protocols/p4runtime/BUILD
new file mode 100644
index 0000000..66e2f59
--- /dev/null
+++ b/protocols/p4runtime/BUILD
@@ -0,0 +1,18 @@
+BUNDLES = [
+    '//protocols/p4runtime/api:onos-protocols-p4runtime-api',
+    '//protocols/p4runtime/ctl:onos-protocols-p4runtime-ctl',
+    '//protocols/p4runtime/model:onos-protocols-p4runtime-model',
+    "//protocols/p4runtime/proto:p4runtime_java_grpc",
+]
+
+onos_app(
+    app_name = 'org.onosproject.protocols.p4runtime',
+    title = 'P4Runtime Protocol Subsystem',
+    category = 'Protocol',
+    url = 'http://onosproject.org',
+    description = 'ONOS P4Runtime protocol subsystem',
+    included_bundles = BUNDLES,
+    required_apps = [
+        'org.onosproject.protocols.grpc'
+    ],
+)
diff --git a/protocols/p4runtime/api/BUILD b/protocols/p4runtime/api/BUILD
index de7b487..531d734 100644
--- a/protocols/p4runtime/api/BUILD
+++ b/protocols/p4runtime/api/BUILD
@@ -1,7 +1,5 @@
-GRPC_VER = "1_3_1"
-
 COMPILE_DEPS = CORE_DEPS + [
-    "@grpc_core_" + GRPC_VER + "//jar",
+    "@io_grpc_grpc_java//core",
 ]
 
 TEST_DEPS = TEST + [
diff --git a/protocols/p4runtime/ctl/BUILD b/protocols/p4runtime/ctl/BUILD
new file mode 100644
index 0000000..13554c7
--- /dev/null
+++ b/protocols/p4runtime/ctl/BUILD
@@ -0,0 +1,28 @@
+COMPILE_DEPS = CORE_DEPS + KRYO + [
+    "//core/store/serializers:onos-core-serializers",
+    "//protocols/grpc/api:onos-protocols-grpc-api",
+    "//protocols/p4runtime/api:onos-protocols-p4runtime-api",
+    "//protocols/p4runtime/proto:p4config_java_proto",
+    "//protocols/p4runtime/proto:p4data_java_proto",
+    "//protocols/p4runtime/proto:p4info_java_proto",
+    "//protocols/p4runtime/proto:p4runtime_java_grpc",
+    "//protocols/p4runtime/proto:p4runtime_java_proto",
+    "//protocols/p4runtime/proto:status_java_proto",
+    "@com_google_protobuf//:protobuf_java",
+    "@io_grpc_grpc_java//context",
+    "@io_grpc_grpc_java//core",
+    "@io_grpc_grpc_java//netty",
+    "@io_grpc_grpc_java//stub",
+    "@io_grpc_grpc_java_core_repkg//:internal",
+]
+
+TEST_DEPS = TEST + [
+    "@minimal_json//jar",
+    "@io_grpc_grpc_java//core:inprocess",
+    "@io_grpc_grpc_java//protobuf-lite",
+]
+
+osgi_jar_with_tests(
+    deps = COMPILE_DEPS,
+    test_deps = TEST_DEPS,
+)
diff --git a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeControllerImpl.java b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeControllerImpl.java
index d8b0cae..1e7326d 100644
--- a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeControllerImpl.java
+++ b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeControllerImpl.java
@@ -20,8 +20,6 @@
 import com.google.common.util.concurrent.Striped;
 import io.grpc.ManagedChannel;
 import io.grpc.ManagedChannelBuilder;
-import io.grpc.NameResolverProvider;
-import io.grpc.internal.DnsNameResolverProvider;
 import io.grpc.netty.NettyChannelBuilder;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
@@ -65,7 +63,6 @@
         implements P4RuntimeController {
 
     private final Logger log = getLogger(getClass());
-    private final NameResolverProvider nameResolverProvider = new DnsNameResolverProvider();
 
     private final Map<DeviceId, ClientKey> clientKeys = Maps.newHashMap();
     private final Map<ClientKey, P4RuntimeClient> clients = Maps.newHashMap();
@@ -141,8 +138,7 @@
 
         ManagedChannelBuilder channelBuilder = NettyChannelBuilder
                 .forAddress(serverAddr, serverPort)
-                .usePlaintext(true)
-                .nameResolverFactory(nameResolverProvider);
+                .usePlaintext(true);
 
         ManagedChannel channel;
         try {
diff --git a/protocols/p4runtime/model/BUILD b/protocols/p4runtime/model/BUILD
index f29c84c..1e7b506 100644
--- a/protocols/p4runtime/model/BUILD
+++ b/protocols/p4runtime/model/BUILD
@@ -1,7 +1,5 @@
-PROTOBUF_VER = "3_2_0"
-
 COMPILE_DEPS = CORE_DEPS + [
-    "//protocols/p4runtime/proto:p4_runtime_java_proto",
+    "//protocols/p4runtime/proto:p4info_java_proto",
     "@com_google_protobuf//:protobuf_java",
 ]
 
diff --git a/protocols/p4runtime/proto/BUILD b/protocols/p4runtime/proto/BUILD
index 8c533af..2da5615 100644
--- a/protocols/p4runtime/proto/BUILD
+++ b/protocols/p4runtime/proto/BUILD
@@ -1,32 +1,58 @@
 load("//tools/build/bazel:osgi_java_library.bzl", "wrapped_osgi_jar")
-
-java_proto_library(
-    name = "p4_runtime_java_proto_proto",
-    visibility = ["//visibility:public"],
-    deps = ["@p4lang_pi//:p4_runtime_proto"],
-)
+load("@io_grpc_grpc_java//:java_grpc_library.bzl", "java_grpc_library")
 
 wrapped_osgi_jar(
-    name = "rpc_java_proto-osgi",
-    jar = "@google_rpc//:rpc_java_proto",
-    visibility = ["//visibility:public"],
-    deps = CORE_DEPS + ["@protobuf_java_3_2_0//jar"],
-)
-
-wrapped_osgi_jar(
-    name = "grpc-core-repkg-1.3.1",
-    jar = "@grpc_src_zip_131//:grpc-core-repkg-1.3.1-native",
-    visibility = ["//visibility:public"],
-    deps = COMPILE,
-)
-
-wrapped_osgi_jar(
-    name = "p4_runtime_java_proto",
-    jar = ":p4_runtime_java_proto_proto",
-    visibility = ["//visibility:public"],
-    deps = CORE_DEPS + [
-        "@protobuf_java_3_2_0//jar",
-        "@google_rpc//:rpc_java_proto",
-        ":grpc-core-repkg-1.3.1",
+    name = "p4config_java_proto",
+    jar = "@com_github_p4lang_pi//:p4config_java_proto_native",
+    deps = [
+        "@com_google_protobuf//:protobuf_java",
     ],
+    visibility = ["//visibility:public"],
+)
+
+wrapped_osgi_jar(
+    name = "p4data_java_proto",
+    jar = "@com_github_p4lang_p4runtime//:p4data_java_proto_native",
+    deps = [
+        "@com_google_protobuf//:protobuf_java",
+    ],
+    visibility = ["//visibility:public"],
+)
+
+wrapped_osgi_jar(
+    name = "p4info_java_proto",
+    jar = "@com_github_p4lang_p4runtime//:p4info_java_proto_native",
+    deps = [
+        "@com_google_protobuf//:protobuf_java",
+    ],
+    visibility = ["//visibility:public"],
+)
+
+wrapped_osgi_jar(
+    name = "p4runtime_java_proto",
+    jar = "@com_github_p4lang_p4runtime//:p4runtime_java_proto_native",
+    deps = [
+        "@com_google_protobuf//:protobuf_java",
+    ],
+    visibility = ["//visibility:public"],
+)
+
+wrapped_osgi_jar(
+    name = "p4runtime_java_grpc",
+    jar = "@com_github_p4lang_p4runtime//:p4runtime_java_grpc_native",
+    deps = [
+        "@io_grpc_grpc_java//stub",
+        "@io_grpc_grpc_java//core",
+        "@io_grpc_grpc_java//protobuf",
+    ],
+    visibility = ["//visibility:public"],
+)
+
+wrapped_osgi_jar(
+    name = "status_java_proto",
+    jar = "@com_github_googleapis//:status_java_proto_native",
+    deps = [
+        "@com_google_protobuf//:protobuf_java",
+    ],
+    visibility = ["//visibility:public"],
 )
diff --git a/protocols/pcep/pcepio/BUCK b/protocols/pcep/pcepio/BUCK
index 3602eb8..e02623d 100644
--- a/protocols/pcep/pcepio/BUCK
+++ b/protocols/pcep/pcepio/BUCK
@@ -6,7 +6,7 @@
     '//lib:osgi-core',
     '//lib:org.apache.karaf.shell.console',
     '//lib:org.apache.felix.scr.annotations',
-    '//lib:netty',
+    '//lib:io_netty_netty',
 ]
 
 osgi_jar_with_tests (
diff --git a/protocols/pcep/pcepio/BUILD b/protocols/pcep/pcepio/BUILD
index 6d51bf7..cfea318 100644
--- a/protocols/pcep/pcepio/BUILD
+++ b/protocols/pcep/pcepio/BUILD
@@ -1,6 +1,6 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
     "@org_apache_karaf_shell_console//jar",
-    "@netty//jar",
+    "@io_netty_netty//jar",
 ]
 
 osgi_jar_with_tests(
diff --git a/protocols/pcep/server/api/BUCK b/protocols/pcep/server/api/BUCK
index 8104425..4c26105 100644
--- a/protocols/pcep/server/api/BUCK
+++ b/protocols/pcep/server/api/BUCK
@@ -3,7 +3,7 @@
     '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
     '//apps/pcep-api:onos-apps-pcep-api',
     '//incubator/api:onos-incubator-api',
-    '//lib:netty',
+    '//lib:io_netty_netty',
 ]
 
 osgi_jar_with_tests (
diff --git a/protocols/pcep/server/api/BUILD b/protocols/pcep/server/api/BUILD
index f69f463..604c1f3 100644
--- a/protocols/pcep/server/api/BUILD
+++ b/protocols/pcep/server/api/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + [
-    "@netty//jar",
+    "@io_netty_netty//jar",
     "//protocols/pcep/pcepio:onos-protocols-pcep-pcepio",
     "//apps/pcep-api:onos-apps-pcep-api",
     "//incubator/api:onos-incubator-api",
diff --git a/protocols/pcep/server/ctl/BUCK b/protocols/pcep/server/ctl/BUCK
index 29e7fbf..5295876 100644
--- a/protocols/pcep/server/ctl/BUCK
+++ b/protocols/pcep/server/ctl/BUCK
@@ -8,7 +8,7 @@
     '//protocols/pcep/server/api:onos-protocols-pcep-server-api',
     '//core/store/serializers:onos-core-serializers',
     '//apps/pcep-api:onos-apps-pcep-api',
-    '//lib:netty',
+    '//lib:io_netty_netty',
 ]
 
 TEST_DEPS = [
diff --git a/protocols/pcep/server/ctl/BUILD b/protocols/pcep/server/ctl/BUILD
index 13a7fa3..463819f 100644
--- a/protocols/pcep/server/ctl/BUILD
+++ b/protocols/pcep/server/ctl/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + KRYO + [
-    "@netty//jar",
+    "@io_netty_netty//jar",
     "//incubator/api:onos-incubator-api",
     "//protocols/pcep/pcepio:onos-protocols-pcep-pcepio",
     "//protocols/pcep/server/api:onos-protocols-pcep-server-api",
diff --git a/protocols/tl1/api/BUCK b/protocols/tl1/api/BUCK
index 3ce3f98..52e0753 100644
--- a/protocols/tl1/api/BUCK
+++ b/protocols/tl1/api/BUCK
@@ -1,6 +1,6 @@
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
-    '//lib:netty-transport',
+    '//lib:io_netty_netty_transport',
 ]
 
 osgi_jar_with_tests (
diff --git a/protocols/tl1/api/BUILD b/protocols/tl1/api/BUILD
index 1b2c9b7..2e32829 100644
--- a/protocols/tl1/api/BUILD
+++ b/protocols/tl1/api/BUILD
@@ -1,5 +1,5 @@
 COMPILE_DEPS = CORE_DEPS + [
-    "@netty_transport//jar",
+    "@io_netty_netty_transport//jar",
 ]
 
 osgi_jar_with_tests(
diff --git a/protocols/tl1/ctl/BUCK b/protocols/tl1/ctl/BUCK
index f451074..af235e4 100644
--- a/protocols/tl1/ctl/BUCK
+++ b/protocols/tl1/ctl/BUCK
@@ -1,9 +1,9 @@
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//lib:NETTY',
-    '//lib:netty-transport',
-    '//lib:netty-buffer',
-    '//lib:netty-codec',
+    '//lib:io_netty_netty_transport',
+    '//lib:io_netty_netty_buffer',
+    '//lib:io_netty_netty_codec',
     '//protocols/tl1/api:onos-protocols-tl1-api',
 ]
 
diff --git a/protocols/tl1/ctl/BUILD b/protocols/tl1/ctl/BUILD
index e74c4bb..162c34c 100644
--- a/protocols/tl1/ctl/BUILD
+++ b/protocols/tl1/ctl/BUILD
@@ -1,6 +1,6 @@
 COMPILE_DEPS = CORE_DEPS + NETTY + [
-    "@netty_transport//jar",
-    "@netty_codec//jar",
+    "@io_netty_netty_transport//jar",
+    "@io_netty_netty_codec//jar",
     "//protocols/tl1/api:onos-protocols-tl1-api",
 ]
 
diff --git a/protocols/xmpp/core/BUCK b/protocols/xmpp/core/BUCK
index 97af973..49a5015 100644
--- a/protocols/xmpp/core/BUCK
+++ b/protocols/xmpp/core/BUCK
@@ -3,10 +3,10 @@
     '//protocols/xmpp/core/ctl:onos-protocols-xmpp-core-ctl',
     '//lib:tinder-xmpp',
     '//lib:org.apache.servicemix.bundles.dom4j',
-    '//lib:netty-common',
-    '//lib:netty-transport',
-    '//lib:netty-buffer',
-    '//lib:netty-codec',
+    '//lib:io_netty_netty_common',
+    '//lib:io_netty_netty_transport',
+    '//lib:io_netty_netty_buffer',
+    '//lib:io_netty_netty_codec',
     '//lib:stax2-api',
     '//lib:aalto-xml',
     '//lib:concurrent-hashmap',
diff --git a/protocols/xmpp/core/BUILD b/protocols/xmpp/core/BUILD
index c3834c8..bfabb8c 100644
--- a/protocols/xmpp/core/BUILD
+++ b/protocols/xmpp/core/BUILD
@@ -1,10 +1,10 @@
 BUNDLES = [
     "@tinder_xmpp//jar",
     "@org_apache_servicemix_bundles_dom4j//jar",
-    "@netty_common//jar",
-    "@netty_transport//jar",
-    "@netty_buffer//jar",
-    "@netty_codec//jar",
+    "@io_netty_netty_common//jar",
+    "@io_netty_netty_transport//jar",
+    "@io_netty_netty_buffer//jar",
+    "@io_netty_netty_codec//jar",
     "@stax2_api//jar",
     "@aalto_xml//jar",
     "@concurrent_hashmap//jar",
diff --git a/protocols/xmpp/core/api/BUCK b/protocols/xmpp/core/api/BUCK
index 8d191ee..1e7a692 100644
--- a/protocols/xmpp/core/api/BUCK
+++ b/protocols/xmpp/core/api/BUCK
@@ -2,8 +2,8 @@
     '//lib:CORE_DEPS',
     '//core/api:onos-api',
     '//lib:tinder-xmpp',
-    '//lib:netty-transport',
-    '//lib:netty-common',
+    '//lib:io_netty_netty_transport',
+    '//lib:io_netty_netty_common',
     '//lib:org.apache.servicemix.bundles.dom4j',
 ]
 
diff --git a/protocols/xmpp/core/api/BUILD b/protocols/xmpp/core/api/BUILD
index 29d19f1..74f0972 100644
--- a/protocols/xmpp/core/api/BUILD
+++ b/protocols/xmpp/core/api/BUILD
@@ -1,7 +1,7 @@
 COMPILE_DEPS = CORE_DEPS + [
     "@tinder_xmpp//jar",
-    "@netty_transport//jar",
-    "@netty_common//jar",
+    "@io_netty_netty_transport//jar",
+    "@io_netty_netty_common//jar",
 ]
 
 osgi_jar_with_tests(
diff --git a/protocols/xmpp/core/ctl/BUCK b/protocols/xmpp/core/ctl/BUCK
index a055257..4ce3ed1 100644
--- a/protocols/xmpp/core/ctl/BUCK
+++ b/protocols/xmpp/core/ctl/BUCK
@@ -1,11 +1,11 @@
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//protocols/xmpp/core/api:onos-protocols-xmpp-core-api',
-    '//lib:netty-common',
-    '//lib:netty-transport',
-    '//lib:netty-transport-native-epoll',
-    '//lib:netty-buffer',
-    '//lib:netty-codec',
+    '//lib:io_netty_netty_common',
+    '//lib:io_netty_netty_transport',
+    '//lib:io_netty_netty_transport-native-epoll',
+    '//lib:io_netty_netty_buffer',
+    '//lib:io_netty_netty_codec',
     '//lib:org.apache.servicemix.bundles.dom4j',
     '//lib:tinder-xmpp',
     '//lib:stax2-api',
diff --git a/protocols/xmpp/core/ctl/BUILD b/protocols/xmpp/core/ctl/BUILD
index 8c521a1..fda6c08 100644
--- a/protocols/xmpp/core/ctl/BUILD
+++ b/protocols/xmpp/core/ctl/BUILD
@@ -1,9 +1,9 @@
 COMPILE_DEPS = CORE_DEPS + [
-    "@netty_common//jar",
-    "@netty_transport//jar",
-    "@netty_transport_native_epoll//jar",
-    "@netty_buffer//jar",
-    "@netty_codec//jar",
+    "@io_netty_netty_common//jar",
+    "@io_netty_netty_transport//jar",
+    "@io_netty_netty_transport_native_epoll//jar",
+    "@io_netty_netty_buffer//jar",
+    "@io_netty_netty_codec//jar",
     "@tinder_xmpp//jar",
     "@stax2_api//jar",
     "@aalto_xml//jar",