Allow building third-party apps based on gRPC

By publishing the repackaged grpc and protobuf artifacts

Change-Id: Ib3af7dba4f64948132aa70be31922de61d6f6ab2
This commit is contained in:
Carmelo Cascone 2019-04-25 13:50:54 -07:00 committed by Ray Milkey
parent 1b5c5fadfe
commit c0b23a459f
27 changed files with 161 additions and 161 deletions

View File

@ -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",

View File

@ -4,7 +4,7 @@ COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + CLI + [
"@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",
]

View File

@ -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",

View File

@ -16,13 +16,13 @@ BUNDLES = [
"@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",

View File

@ -12,8 +12,8 @@ COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + CLI + REST + [
"@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",

View File

@ -4,8 +4,8 @@ COMPILE_DEPS = CORE_DEPS + KRYO + JACKSON + [
"//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",

View File

@ -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",

View File

@ -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",

View File

@ -3,7 +3,7 @@ COMPILE_DEPS = CORE_DEPS + KRYO + [
"//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 = [

View File

@ -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",

66
lib/BUILD Normal file
View File

@ -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 = [],
)

View File

@ -3,18 +3,18 @@ COMPILE_DEPS = CORE_DEPS + KRYO + [
"//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(

View File

@ -3,18 +3,18 @@ COMPILE_DEPS = CORE_DEPS + KRYO + [
"//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(

View File

@ -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 @@ onos_app(
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 = [],
)

View File

@ -1,3 +1,3 @@
osgi_jar(
deps = CORE_DEPS + ["@io_grpc_grpc_java//core"],
deps = CORE_DEPS + ["//lib:io_grpc_grpc_core_context"],
)

View File

@ -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",
]

View File

@ -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(

View File

@ -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 + [

View File

@ -4,18 +4,18 @@ COMPILE_DEPS = CORE_DEPS + KRYO + [
"//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(

View File

@ -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(

View File

@ -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",
]

View File

@ -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"

View File

@ -364,7 +364,8 @@ def wrapped_osgi_jar(
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 @@ def wrapped_osgi_jar(
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 @@ def osgi_proto_jar(
":%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 @@ def osgi_proto_jar(
)
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,

View File

@ -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():

View File

@ -4,6 +4,3 @@ ONOS_GROUP_ID = "org.onosproject"
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"

View File

@ -33,6 +33,14 @@ function jars {
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 @@ writeCatalog $(testJars)
[ $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/')

View File

@ -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