Updating BUCK files

Change-Id: I24f279b42a270e59cf4bf4564e2aa4d81459c8e2
diff --git a/core/common/BUCK b/core/common/BUCK
index 70ea817..a00d4fd 100644
--- a/core/common/BUCK
+++ b/core/common/BUCK
@@ -1,8 +1,3 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-CURRENT_NAME = 'onos-core-common'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 SRC_DEPS = [
     '//lib:CORE_DEPS',
     '//incubator/api:onos-incubator-api',
@@ -13,21 +8,9 @@
     '//core/api:onos-api-tests',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
+    name = 'onos-core-common',
     deps = SRC_DEPS,
+    test_deps = TEST_DEPS,
     visibility = ['PUBLIC'],
 )
-
-java_test(
-    name = 'onos-core-common-tests',
-    visibility = ['PUBLIC'],
-    srcs = glob([TEST + '/*.java']),
-    resources_root = 'src/test/resources',
-    resources = glob(['src/test/resources/**']),
-    deps = SRC_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
-)
diff --git a/core/net/BUCK b/core/net/BUCK
index bffb300..7070fb7 100644
--- a/core/net/BUCK
+++ b/core/net/BUCK
@@ -1,8 +1,3 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-CURRENT_NAME = 'onos-core-net'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//incubator/api:onos-incubator-api',
@@ -15,20 +10,9 @@
     '//core/store/dist:onos-core-dist-tests',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
+    name = 'onos-core-net',
     deps = COMPILE_DEPS,
+    test_deps = TEST_DEPS,
     visibility = ['PUBLIC'],
-)
-
-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/**']),
-)
+)
\ No newline at end of file
diff --git a/core/store/dist/BUCK b/core/store/dist/BUCK
index 6c56b3f..075612f 100644
--- a/core/store/dist/BUCK
+++ b/core/store/dist/BUCK
@@ -1,8 +1,3 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-CURRENT_NAME = 'onos-core-dist'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//core/common:onos-core-common',
@@ -18,23 +13,13 @@
 
 TEST_DEPS = [
     '//lib:TEST',
-     '//core/api:onos-api-tests',
-     '//core/common:onos-core-common-tests',
+    '//core/api:onos-api-tests',
+    '//core/common:onos-core-common-tests',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
+    name = 'onos-core-dist',
     deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
-)
-
-java_test(
-    name= 'onos-core-dist-tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
+    test_deps = TEST_DEPS,
     visibility = ['PUBLIC'],
 )
diff --git a/core/store/persistence/BUCK b/core/store/persistence/BUCK
index 0791c14..496160d 100644
--- a/core/store/persistence/BUCK
+++ b/core/store/persistence/BUCK
@@ -1,8 +1,3 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-CURRENT_NAME = 'onos-core-persistence'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//lib:catalyst-serializer',
@@ -13,18 +8,9 @@
     '//lib:TEST',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
+    name = 'onos-core-persistence',
     deps = COMPILE_DEPS,
+    test_deps = TEST_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/core/store/primitives/BUCK b/core/store/primitives/BUCK
index ffdb294..c4a9b8f 100644
--- a/core/store/primitives/BUCK
+++ b/core/store/primitives/BUCK
@@ -1,8 +1,3 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-CURRENT_NAME = 'onos-core-primitives'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//core/common:onos-core-common',
@@ -32,18 +27,9 @@
     '//core/api:onos-api-tests',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
+    name = 'onos-core-primitives',
     deps = COMPILE_DEPS,
+    test_deps = TEST_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/core/store/serializers/BUCK b/core/store/serializers/BUCK
index f5d9ced..1b8efcf 100644
--- a/core/store/serializers/BUCK
+++ b/core/store/serializers/BUCK
@@ -1,8 +1,3 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-CURRENT_NAME = 'onos-core-serializers'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//incubator/api:onos-incubator-api',
@@ -12,18 +7,9 @@
     '//lib:TEST',
 ]
 
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
+osgi_jar_with_tests (
+    name = 'onos-core-serializers',
     deps = COMPILE_DEPS,
+    test_deps = TEST_DEPS,
     visibility = ['PUBLIC'],
 )
-
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
-)