OSGI artifacts now carry Java compilation information

- java provider information produced for OSGI jar files
- osgi jar rule can now be used as a Java dependency
- osgi artifact is the public artifact for a given rule

Change-Id: I4c0a080537f712a3579b02e82e8da9238cb0ac44
diff --git a/tools/build/bazel/onos_app.bzl b/tools/build/bazel/onos_app.bzl
index aec244d..574b654 100644
--- a/tools/build/bazel/onos_app.bzl
+++ b/tools/build/bazel/onos_app.bzl
@@ -296,7 +296,7 @@
     # rule to generate the OAR file based on the app.xml, features.xml, and app jar file
     _onos_oar(
         name = name + "-oar",
-        jar_file = Label(_local_label(name, "-osgi")),
+        jar_file = Label(_local_label(name, "")),
         app_xml = Label(_local_label(name, "-app-xml")),
         feature_xml = Label(_local_label(name, "-feature-xml")),
         feature_xml_coords = feature_xml_coords,
diff --git a/tools/build/bazel/osgi_features.bzl b/tools/build/bazel/osgi_features.bzl
index 7c29e78..613bf7b 100644
--- a/tools/build/bazel/osgi_features.bzl
+++ b/tools/build/bazel/osgi_features.bzl
@@ -39,13 +39,15 @@
     inputs = []
     for dep in ctx.attr.included_bundles:
         args += ["-b", maven_coordinates(dep.label)]
-        for f in dep.java.outputs.jars:
-            inputs += [f.class_jar]
 
-    for dep in ctx.attr.excluded_bundles:
-        args += ["-e", maven_coordinates(dep.label)]
-        for f in dep.java.outputs.jars:
-            inputs += [f.class_jar]
+        for f in ctx.attr.included_bundles:
+            if java_common.provider in f:
+                inputs += [f.files.to_list()[0]]
+
+        for f in ctx.attr.excluded_bundles:
+            args += ["-e", maven_coordinates(dep.label)]
+            if java_common.provider in f:
+                inputs += [f.files.to_list()[0]]
 
     for f in ctx.attr.required_features:
         args += ["-f", f]
diff --git a/tools/build/bazel/osgi_java_library.bzl b/tools/build/bazel/osgi_java_library.bzl
index 8e4fb56..77d791b 100644
--- a/tools/build/bazel/osgi_java_library.bzl
+++ b/tools/build/bazel/osgi_java_library.bzl
@@ -64,15 +64,13 @@
 
     # determine the dependencies and build the class path
     for dep in ctx.attr.deps:
-        if len(dep.java.outputs.jars) == 0:
-            continue
+        if java_common.provider in dep:
+            file = dep.files.to_list()[0]
 
-        file = dep.java.outputs.jars[0].class_jar
-
-        if cp:
-            cp += ":"
-        cp += file.path
-        inputDependencies = inputDependencies + [file]
+            if cp:
+                cp += ":"
+            cp += file.path
+            inputDependencies = inputDependencies + [file]
 
     # extract the class files for use by bnd
     classes = ctx.actions.declare_file("classes" + ctx.label.name.replace("/", "-"))
@@ -111,6 +109,15 @@
         executable = ctx.executable._bnd_exe,
     )
 
+    deps = []
+    if java_common.provider in ctx.attr.source:
+        deps.append(ctx.attr.source[java_common.provider])
+    deps_provider = java_common.merge(deps)
+    return struct(
+        providers = [deps_provider]
+    )
+
+
 _bnd = rule(
     attrs = {
         "deps": attr.label_list(),
@@ -172,10 +179,10 @@
     tests_jar_deps = list(depset(deps + test_deps)) + [name]
     all_test_deps = tests_jar_deps + [tests_name]
 
-    native.java_library(name = name, srcs = srcs, resources = resources, deps = deps, visibility = visibility)
+    native.java_library(name = name + "-native", srcs = srcs, resources = resources, deps = deps, visibility = visibility)
     _bnd(
-        name = name + "-osgi",
-        source = name,
+        name = name,
+        source = name + "-native",
         deps = deps,
         version = version,
         package_name_root = package_name_root,