Refactoring of provider buck builds.

Change-Id: I9b5e2566b83c13a8b7b086005a08a8182305ffdb
diff --git a/BUCK b/BUCK
index 71efbd2..3336d39 100644
--- a/BUCK
+++ b/BUCK
@@ -26,8 +26,8 @@
     '//protocols/bgp/bgpio:onos-bgpio',
     '//protocols/bgp/api:onos-bgp-api',
     '//protocols/bgp/ctl:onos-bgp-ctl',
-    '//protocols/netconf/api:onos-netconf-api',
-    '//protocols/netconf/ctl:onos-netconf-ctl',
+    '//protocols/netconf/api:onos-protocols-netconf-api',
+    '//protocols/netconf/ctl:onos-protocols-netconf-ctl',
     '//protocols/openflow/api:onos-of-api',
     '//protocols/openflow/ctl:onos-of-ctl',
     '//protocols/ospf/api:onos-ospf-api',
@@ -54,24 +54,13 @@
     '//drivers/netconf:onos-drivers-netconf',
     '//drivers/ovsdb:onos-drivers-ovsdb',
 
-    '//providers/bgp/cfg:onos-bgp-provider-cfg',
-    '//providers/bgp/flow:onos-bgp-provider-flow',
-    '//providers/bgp/topology:onos-bgp-provider-topology',
-    '//providers/host:onos-host-provider',
-    '//providers/lldpcommon:onos-lldp-provider-common',
-    '//providers/netcfglinks:onos-netcfg-links-provider',
-    '//providers/lldp:onos-lldp-provider',
-    '//providers/netconf/device:onos-netconf-provider-device',
-    '//providers/netcfghost:onos-netcfg-links-provider',
-    '//providers/null:onos-null-providers',
-    '//providers/openflow/device:onos-of-provider-device',
-    '//providers/openflow/flow:onos-of-provider-flow',
-    '//providers/openflow/group:onos-of-provider-group',
-    '//providers/openflow/message:onos-of-provider-message',
-    '//providers/openflow/meter:onos-of-provider-meter',
-    '//providers/openflow/packet:onos-of-provider-packet',
+    '//providers/netconf/device:onos-providers-netconf-device',
+    '//providers/openflow/device:onos-providers-openflow-device',
+    '//providers/openflow/packet:onos-providers-openflow-packet',
+    '//providers/openflow/flow:onos-providers-openflow-flow',
+    '//providers/openflow/group:onos-providers-openflow-group',
+    '//providers/openflow/meter:onos-providers-openflow-meter',
     '//providers/ovsdb/device:onos-ovsdb-provider-device',
-    '//providers/ovsdb/host:onos-ovsdb-provider-host',
     '//providers/ovsdb/tunnel:onos-ovsdb-provider-tunnel',
     '//providers/rest/device:onos-restsb-provider-device',
     '//providers/snmp/device:onos-snmp-provider-device',
@@ -81,8 +70,20 @@
 ]
 
 APPS = [
-    '//providers/pcep:onos-providers-pcep-oar',
+    # Providers
+    '//providers/bgp:onos-providers-bgp-oar',
+    '//providers/host:onos-providers-host-oar',
+    '//providers/lldp:onos-providers-lldp-oar',
+    '//providers/netcfghost:onos-providers-netcfghost-oar',
+    '//providers/netcfglinks:onos-providers-netcfglinks-oar',
+    '//providers/netconf:onos-providers-netconf-oar',
+    '//providers/openflow/message:onos-providers-openflow-message-oar',
     '//providers/ovsdb:onos-providers-ovsdb-oar',
+    '//providers/pcep:onos-providers-pcep-oar',
+    '//providers/null:onos-providers-null-oar',
+    '//providers/openflow/base:onos-providers-openflow-base-oar',
+
+    # Apps
     '//apps/dhcp:onos-apps-dhcp-oar',
     '//apps/fwd:onos-apps-fwd-oar',
     '//apps/aaa:onos-apps-aaa-oar',
@@ -117,11 +118,11 @@
     '//apps/vtn:onos-apps-vtn-oar',
     '//apps/faultmanagement:onos-apps-faultmanagement-oar',
     '//apps/openstacknode:onos-apps-openstacknode-oar',
+    '//apps/cpman/app:onos-apps-cpman-app-oar',
 ]
 
 APP_JARS = [
-    '//apps/cpman/api:onos-app-cpman-api',
-    '//apps/cpman/app:onos-app-cpman-app',
+    '//apps/cpman/api:onos-apps-cpman-api',
     '//apps/routing-api:onos-apps-routing-api',
     '//apps/cip:onos-app-cip',
     '//apps/dhcp/api:onos-apps-dhcp-api',
diff --git a/apps/cpman/api/BUCK b/apps/cpman/api/BUCK
index 156a545..4cb1ba0 100644
--- a/apps/cpman/api/BUCK
+++ b/apps/cpman/api/BUCK
@@ -1,9 +1,3 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-app-cpman-api'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//core/store/serializers:onos-core-serializers',
@@ -13,18 +7,8 @@
     '//lib:TEST_ADAPTERS',
 ]
 
-java_library(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
+    test_deps = TEST_DEPS,
 )
 
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
-)
diff --git a/apps/cpman/app/BUCK b/apps/cpman/app/BUCK
index 7a78bab..4dbe55a 100644
--- a/apps/cpman/app/BUCK
+++ b/apps/cpman/app/BUCK
@@ -1,15 +1,9 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-app-cpman-app'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//lib:org.apache.karaf.shell.console',
     '//lib:javax.ws.rs-api',
     '//lib:rrd4j',
-    '//apps/cpman/api:onos-app-cpman-api',
+    '//apps/cpman/api:onos-apps-cpman-api',
     '//utils/rest:onlab-rest',
     '//cli:onos-cli',
     '//core/store/serializers:onos-core-serializers',
@@ -20,20 +14,24 @@
     '//web/api:onos-rest-tests',
 ]
 
-java_library(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+BUNDLES = [
+    '//apps/cpman/api:onos-apps-cpman-api',
+]
+
+EXCLUDED_BUNDLES = [
+    '//lib:rrd4j', # FIXME - needs wrap
+]
+
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
+    test_deps = TEST_DEPS,
 )
 
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
-    resources_root = 'src/test/resources',
-    resources = glob(['src/test/resources/**']),
+onos_app (
+    title = 'Control Plane Manager REST API',
+    category = 'Provider',
+    url = 'http://onosproject.org',
+    description = 'APIs for interacting with the Control Plane Management application.',
+    included_bundles = BUNDLES,
+    excluded_bundles = EXCLUDED_BUNDLES,
 )
diff --git a/drivers/cisco/BUCK b/drivers/cisco/BUCK
index 0b538d7..2b2e184 100644
--- a/drivers/cisco/BUCK
+++ b/drivers/cisco/BUCK
@@ -6,7 +6,7 @@
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//drivers/utilities:onos-drivers-utilities',
-    '//protocols/netconf/api:onos-netconf-api',
+    '//protocols/netconf/api:onos-protocols-netconf-api',
 ]
 
 osgi_jar(
diff --git a/drivers/fujitsu/BUCK b/drivers/fujitsu/BUCK
index 373b7d9..38643b7 100644
--- a/drivers/fujitsu/BUCK
+++ b/drivers/fujitsu/BUCK
@@ -6,7 +6,7 @@
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//drivers/utilities:onos-drivers-utilities',
-    '//protocols/netconf/api:onos-netconf-api',
+    '//protocols/netconf/api:onos-protocols-netconf-api',
 ]
 
 osgi_jar(
diff --git a/drivers/netconf/BUCK b/drivers/netconf/BUCK
index bec65c4..0ba3c5d 100644
--- a/drivers/netconf/BUCK
+++ b/drivers/netconf/BUCK
@@ -6,7 +6,7 @@
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//drivers/utilities:onos-drivers-utilities',
-    '//protocols/netconf/api:onos-netconf-api',
+    '//protocols/netconf/api:onos-protocols-netconf-api',
 ]
 
 osgi_jar(
diff --git a/protocols/netconf/api/BUCK b/protocols/netconf/api/BUCK
index 28ac267..943b11d 100644
--- a/protocols/netconf/api/BUCK
+++ b/protocols/netconf/api/BUCK
@@ -1,15 +1,7 @@
-SRC = 'src/main/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-netconf-api'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
 ]
 
 osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
 )
diff --git a/protocols/netconf/ctl/BUCK b/protocols/netconf/ctl/BUCK
index 8ff5134..6c11e25 100644
--- a/protocols/netconf/ctl/BUCK
+++ b/protocols/netconf/ctl/BUCK
@@ -1,30 +1,10 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-CURRENT_NAME = 'onos-netconf-ctl'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//lib:ganymed-ssh2',
-    '//protocols/netconf/api:onos-netconf-api'
+    '//protocols/netconf/api:onos-protocols-netconf-api'
 ]
 
-TEST_DEPS = [
-    '//lib:TEST',
-]
-
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
 )
 
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
-)
diff --git a/providers/bgp/BUCK b/providers/bgp/BUCK
new file mode 100644
index 0000000..c526f55
--- /dev/null
+++ b/providers/bgp/BUCK
@@ -0,0 +1,17 @@
+BUNDLES = [
+    '//providers/bgp/cfg:onos-providers-bgp-cfg',
+    '//providers/bgp/flow:onos-providers-bgp-flow',
+    '//providers/bgp/topology:onos-providers-bgp-topology',
+    '//protocols/bgp/api:onos-bgp-api',
+    '//protocols/bgp/ctl:onos-bgp-ctl',
+    '//protocols/bgp/bgpio:onos-bgpio',
+]
+
+onos_app (
+    title = 'BGP Provider',
+    category = 'Provider',
+    url = 'http://onosproject.org',
+    included_bundles = BUNDLES,
+    description = 'BGP protocol southbound providers.',
+)
+
diff --git a/providers/bgp/cfg/BUCK b/providers/bgp/cfg/BUCK
index 3156e95..917fc34 100644
--- a/providers/bgp/cfg/BUCK
+++ b/providers/bgp/cfg/BUCK
@@ -1,16 +1,8 @@
-SRC = 'src/main/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-bgp-provider-cfg'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//protocols/bgp/api:onos-bgp-api',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
 )
diff --git a/providers/bgp/flow/BUCK b/providers/bgp/flow/BUCK
index ba18ec5..917fc34 100644
--- a/providers/bgp/flow/BUCK
+++ b/providers/bgp/flow/BUCK
@@ -1,16 +1,8 @@
-SRC = 'src/main/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-bgp-provider-flow'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//protocols/bgp/api:onos-bgp-api',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
 )
diff --git a/providers/bgp/topology/BUCK b/providers/bgp/topology/BUCK
index 3d3aad6..e4e7041 100644
--- a/providers/bgp/topology/BUCK
+++ b/providers/bgp/topology/BUCK
@@ -1,9 +1,3 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-bgp-provider-topology'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//protocols/bgp/api:onos-bgp-api',
@@ -15,18 +9,7 @@
     '//lib:TEST_ADAPTERS',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
-)
-
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
+    test_deps = TEST_DEPS,
 )
diff --git a/providers/host/BUCK b/providers/host/BUCK
index 80f921c..2d52e05 100644
--- a/providers/host/BUCK
+++ b/providers/host/BUCK
@@ -1,15 +1,20 @@
-SRC = 'src/main/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-host-provider'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+TEST_DEPS = [
+    '//lib:TEST_ADAPTERS',
+    '//utils/osgi:onlab-osgi-tests',
+]
+
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
+    test_deps = TEST_DEPS,
+)
+
+onos_app (
+    title = 'Host Location Provider',
+    category = 'Provider',
+    url = 'http://onosproject.org',
+    description = 'ONOS host location provider.',
 )
diff --git a/providers/lldp/BUCK b/providers/lldp/BUCK
index ce40918..aae471f 100644
--- a/providers/lldp/BUCK
+++ b/providers/lldp/BUCK
@@ -1,30 +1,27 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-lldp-provider'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
-    '//providers/lldpcommon:onos-lldp-provider-common',
+    '//providers/lldpcommon:onos-providers-lldpcommon',
 ]
 
 TEST_DEPS = [
     '//lib:TEST_ADAPTERS',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+BUNDLES = [
+    '//providers/lldpcommon:onos-providers-lldpcommon',
+    '//providers/lldp:onos-providers-lldp',
+]
+
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
+    test_deps = TEST_DEPS,
 )
 
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
+onos_app (
+    title = 'LLDP Link Provider',
+    category = 'Provider',
+    url = 'http://onosproject.org',
+    description = 'ONOS LLDP Link provider.',
+    included_bundles = BUNDLES,
 )
+
diff --git a/providers/lldpcommon/BUCK b/providers/lldpcommon/BUCK
index f4b3b21..0e34257 100644
--- a/providers/lldpcommon/BUCK
+++ b/providers/lldpcommon/BUCK
@@ -1,9 +1,3 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-lldp-provider-common'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
 ]
@@ -12,18 +6,8 @@
     '//lib:TEST',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
+    test_deps = TEST_DEPS,
 )
 
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
-)
diff --git a/providers/netcfghost/BUCK b/providers/netcfghost/BUCK
index c0341d1..3ef52ef 100644
--- a/providers/netcfghost/BUCK
+++ b/providers/netcfghost/BUCK
@@ -1,29 +1,15 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-netcfg-links-provider'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
 ]
 
-TEST_DEPS = [
-    '//lib:TEST',
-]
-
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
 )
 
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
+onos_app (
+    title = 'Network Config Host Provider',
+    category = 'Provider',
+    url = 'http://onosproject.org',
+    description = 'Host provider that uses network config service to discover hosts.',
 )
+
diff --git a/providers/netcfglinks/BUCK b/providers/netcfglinks/BUCK
index 78866ad..785abd2 100644
--- a/providers/netcfglinks/BUCK
+++ b/providers/netcfglinks/BUCK
@@ -1,30 +1,26 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-netcfg-links-provider'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
-    '//providers/lldpcommon:onos-lldp-provider-common',
+    '//providers/lldpcommon:onos-providers-lldpcommon',
 ]
 
 TEST_DEPS = [
     '//lib:TEST_ADAPTERS',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+BUNDLES = [
+    '//providers/lldpcommon:onos-providers-lldpcommon',
+    '//providers/netcfglinks:onos-providers-netcfglinks',
+]
+
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
+    test_deps = TEST_DEPS,
 )
 
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
+onos_app (
+    title = 'Network Config Link Provider',
+    category = 'Provider',
+    url = 'http://onosproject.org',
+    description = 'Links provider that uses network config service to predefine devices and links.',
+    included_bundles = BUNDLES,
 )
diff --git a/providers/netconf/BUCK b/providers/netconf/BUCK
new file mode 100644
index 0000000..0675902
--- /dev/null
+++ b/providers/netconf/BUCK
@@ -0,0 +1,20 @@
+BUNDLES = [
+    '//providers/netconf/device:onos-providers-netconf-device',
+    '//protocols/netconf/api:onos-protocols-netconf-api',
+    '//protocols/netconf/ctl:onos-protocols-netconf-ctl',
+]
+
+EXCLUDED_BUNDLES = [
+    '//lib:ganymed-ssh2', # FIXME - Needs wrap
+]
+
+onos_app (
+    title = 'NETCONF Provider',
+    category = 'Provider',
+    url = 'http://onosproject.org',
+    included_bundles = BUNDLES,
+    excluded_bundles = EXCLUDED_BUNDLES,
+    description = 'NETCONF protocol southbound providers.',
+)
+
+
diff --git a/providers/netconf/device/BUCK b/providers/netconf/device/BUCK
index 74307dd..569ee07 100644
--- a/providers/netconf/device/BUCK
+++ b/providers/netconf/device/BUCK
@@ -1,17 +1,9 @@
-SRC = 'src/main/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-netconf-provider-device'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//incubator/api:onos-incubator-api',
-    '//protocols/netconf/api:onos-netconf-api',
+    '//protocols/netconf/api:onos-protocols-netconf-api',
 ]
 
 osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
 )
diff --git a/providers/null/BUCK b/providers/null/BUCK
index 7ac6ee6..dcb01a2 100644
--- a/providers/null/BUCK
+++ b/providers/null/BUCK
@@ -1,31 +1,19 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-null-providers'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//lib:org.apache.karaf.shell.console',
     '//cli:onos-cli',
 ]
 
-TEST_DEPS = [
-    '//lib:TEST',
-]
-
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
+    resources_root = 'src/main/resources',
+    resources = glob(['src/main/resources/**']),
+    import_packages = '*,org.onosproject.cli.net',
 )
 
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
+onos_app (
+    title = 'Null Southbound Provider',
+    category = 'Provider',
+    url = 'http://onosproject.org',
+    description = 'ONOS null southbound provider.',
 )
diff --git a/providers/openflow/base/BUCK b/providers/openflow/base/BUCK
new file mode 100644
index 0000000..2d3cbfa
--- /dev/null
+++ b/providers/openflow/base/BUCK
@@ -0,0 +1,18 @@
+BUNDLES = [
+    '//lib:openflowj',
+    '//protocols/openflow/api:onos-of-api',
+    '//protocols/openflow/ctl:onos-of-ctl',
+    '//providers/openflow/device:onos-providers-openflow-device',
+    '//providers/openflow/packet:onos-providers-openflow-packet',
+    '//providers/openflow/flow:onos-providers-openflow-flow',
+    '//providers/openflow/group:onos-providers-openflow-group',
+    '//providers/openflow/meter:onos-providers-openflow-meter',
+]
+
+onos_app (
+    title = 'OpenFlow Provider',
+    category = 'Provider',
+    url = 'http://onosproject.org',
+    description = 'OpenFlow protocol southbound providers.',
+    included_bundles = BUNDLES,
+)
diff --git a/providers/openflow/device/BUCK b/providers/openflow/device/BUCK
index 4b87aa4..11599d5 100644
--- a/providers/openflow/device/BUCK
+++ b/providers/openflow/device/BUCK
@@ -1,9 +1,3 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-of-provider-device'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//lib:openflowj',
@@ -14,18 +8,7 @@
     '//lib:TEST_ADAPTERS',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
-)
-
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
+    test_deps = TEST_DEPS,
 )
diff --git a/providers/openflow/flow/BUCK b/providers/openflow/flow/BUCK
index cc8ac28..d575458 100644
--- a/providers/openflow/flow/BUCK
+++ b/providers/openflow/flow/BUCK
@@ -1,31 +1,10 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-of-provider-flow'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//lib:openflowj',
     '//protocols/openflow/api:onos-of-api',
 ]
 
-TEST_DEPS = [
-    '//lib:TEST',
-]
-
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
 )
 
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
-)
diff --git a/providers/openflow/group/BUCK b/providers/openflow/group/BUCK
index 2d176ab..44ad141 100644
--- a/providers/openflow/group/BUCK
+++ b/providers/openflow/group/BUCK
@@ -1,32 +1,10 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-of-provider-group'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//lib:openflowj',
     '//protocols/openflow/api:onos-of-api',
-    '//providers/openflow/flow:onos-of-provider-flow',
+    '//providers/openflow/flow:onos-providers-openflow-flow',
 ]
 
-TEST_DEPS = [
-    '//lib:TEST',
-]
-
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
-)
-
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
 )
diff --git a/providers/openflow/message/BUCK b/providers/openflow/message/BUCK
index dff2a84..8e7da43 100644
--- a/providers/openflow/message/BUCK
+++ b/providers/openflow/message/BUCK
@@ -1,32 +1,23 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-of-provider-message'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//lib:openflowj',
     '//protocols/openflow/api:onos-of-api',
-    '//apps/cpman/api:onos-app-cpman-api',
+    '//apps/cpman/api:onos-apps-cpman-api',
 ]
 
-TEST_DEPS = [
-    '//lib:TEST',
+BUNDLES = [
+    '//apps/cpman/api:onos-apps-cpman-api',
+    ':onos-providers-openflow-message',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
 )
 
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
+onos_app (
+    title = 'Control Message Stats Provider',
+    category = 'Provider',
+    url = 'http://onosproject.org',
+    description = 'ONOS OpenFlow control message provider.',
+    included_bundles = BUNDLES,
 )
diff --git a/providers/openflow/meter/BUCK b/providers/openflow/meter/BUCK
index 9eae14a..6e986a7 100644
--- a/providers/openflow/meter/BUCK
+++ b/providers/openflow/meter/BUCK
@@ -1,31 +1,9 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-of-provider-meter'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//lib:openflowj',
     '//protocols/openflow/api:onos-of-api',
 ]
 
-TEST_DEPS = [
-    '//lib:TEST',
-]
-
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
-)
-
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
 )
diff --git a/providers/openflow/packet/BUCK b/providers/openflow/packet/BUCK
index b209b2b..d575458 100644
--- a/providers/openflow/packet/BUCK
+++ b/providers/openflow/packet/BUCK
@@ -1,31 +1,10 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-of-provider-packet'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//lib:openflowj',
     '//protocols/openflow/api:onos-of-api',
 ]
 
-TEST_DEPS = [
-    '//lib:TEST',
-]
-
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
 )
 
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
-)
diff --git a/providers/pcep/BUCK b/providers/pcep/BUCK
index ccf3969..e333fc9 100644
--- a/providers/pcep/BUCK
+++ b/providers/pcep/BUCK
@@ -5,10 +5,6 @@
     '//protocols/pcep/pcepio:onos-pcep-pcepio',
 ]
 
-COMPILE_DEPS = [
-    '//lib:CORE_DEPS',
-]
-
 onos_app (
     title = 'PCEP Provider',
     category = 'Provider',