Brian O'Connor

Using $(maven_coords :target) marco

Note: This this macro is not yet available on buck master

Also, simplifying app/fwd buck file and improving onos_app
readability by using feature_coords instead of feature_name

Change-Id: I9aff07d66331a537f6711bf15fd760cf910f1afc
BUNDLES = [
('//apps/dhcp/api:onos-app-dhcp-api', ONOS_GROUP_ID + ':' + 'onos-app-dhcp-api' + ':' + ONOS_VERSION),
('//apps/dhcp/app:onos-app-dhcp-app', ONOS_GROUP_ID + ':' + 'onos-app-dhcp-app' + ':' + ONOS_VERSION),
'//apps/dhcp/api:onos-app-dhcp-api',
'//apps/dhcp/app:onos-app-dhcp-app',
]
onos_app(
app_name = 'org.onosproject.dhcp',
feature_name = ONOS_GROUP_ID + ':onos-app-dhcp:' + ONOS_VERSION,
feature_coords = ONOS_GROUP_ID + ':onos-app-dhcp:' + ONOS_VERSION,
title = 'DHCP Server App',
category = 'Utility',
url = 'http://onosproject.org',
......
SRC = 'src/main/java/org/onosproject/**/'
TEST = 'src/test/java/org/onosproject/**/'
CURRENT_NAME = 'onos-app-fwd'
CURRENT_TARGET = ':' + CURRENT_NAME
......@@ -18,27 +15,16 @@ osgi_jar(
name = CURRENT_NAME,
srcs = glob([SRC + '/*.java']),
deps = COMPILE_DEPS,
test_srcs = glob([TEST + '/*.java']),
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],
)
BUNDLES = [
(CURRENT_TARGET, ONOS_GROUP_ID + ':' + CURRENT_NAME + ':' + ONOS_VERSION),
]
onos_app(
app_name = 'org.onosproject.fwd',
title = 'Reactive Forwarding App',
category = 'Traffic Steering',
url = 'http://onosproject.org',
description = 'Reactive forwarding application using flow subsystem.',
included_bundles = BUNDLES,
included_bundles = [ CURRENT_TARGET ],
)
\ No newline at end of file
......
......@@ -96,7 +96,7 @@ if __name__ == '__main__':
import sys, optparse
parser = optparse.OptionParser()
parser.add_option("-n", "--name", dest="feature_name", help="Feature Name")
parser.add_option("-n", "--name", dest="feature_coords", help="Feature MVN Coords")
parser.add_option("-a", "--app", dest="app_name", help="App Name")
parser.add_option("-o", "--origin", dest="origin", help="Origin")
parser.add_option("-c", "--category", dest="category", help="Category")
......@@ -124,8 +124,8 @@ if __name__ == '__main__':
(options, args) = parser.parse_args()
values = {}
if options.feature_name and options.version and options.title:
values['feature_name'] = options.feature_name.split(':')[1]
if options.feature_coords and options.version and options.title:
values['feature_name'] = options.feature_coords.split(':')[1]
values['version'] = options.version
values['title'] = options.title
else:
......@@ -144,7 +144,7 @@ if __name__ == '__main__':
sys.exit(1)
values['feature_repo_name'] = options.repo_name if options.repo_name \
else options.feature_name
else options.feature_coords
if options.write_features:
bundles = []
......
......@@ -16,8 +16,9 @@ def generateOar(output, files=[]):
extension = filename.split('.')[-1]
if extension == 'jar':
filename = '%s-%s.jar' % ( artifactId, version )
elif 'features.xml' in filename:
filename = '%s-%s-features.xml' % ( artifactId, version )
dest = 'm2/%s/%s/%s/%s' % ( groupId, artifactId, version, filename )
print file, '->', dest
zip.write(file, dest)
if __name__ == '__main__':
......
......@@ -93,8 +93,6 @@ def osgi_jar(
visibility = visibility,
)
### Checkstyle
chk_cmd = ' '.join(( 'java -jar $(location //lib:checkstyle)',
'-o $OUT',
......@@ -132,7 +130,7 @@ def osgi_jar(
if test_resources and not test_resources_root:
test_resources_root = RESOURCES_ROOT
if test_srcs:
if test_srcs is not None:
java_test(
name = 'tests',
srcs = test_srcs,
......
......@@ -11,17 +11,17 @@ def onos_app(
url = None,
description = None, #TODO make this a file
#TODO icon,
feature_name = None,
feature_coords = None,
required_features = [ 'onos-api' ],
required_apps = [],
included_bundles = [],
excluded_bundles = [],
**kwargs):
if not feature_name and len(included_bundles) == 1:
feature_name = included_bundles[0][1]
if not feature_coords and len(included_bundles) == 1:
feature_coords = '$(maven_coords %s)' % included_bundles[0]
args = [ '-n %s' % feature_name,
args = [ '-n %s' % feature_coords,
'-v %s' % version,
'-t "%s"' % title,
'-o "%s"' % origin,
......@@ -30,15 +30,15 @@ def onos_app(
'-u %s' % url,
]
args += [ '-f %s' % f for f in required_features ]
args += [ '-b %s' % b for (t, b) in included_bundles ]
args += [ '-e %s' % b for (t, b) in excluded_bundles ]
args += [ '-b $(maven_coords %s)' % b for b in included_bundles ]
args += [ '-e $(maven_coords %s)' % b for b in excluded_bundles ]
args += [ '-d %s' % a for a in required_apps ]
cmd = '$(exe //buck-tools:onos-app-writer) -F ' + ' '.join(args) + ' > $OUT'
genrule(
name = 'app-features',
bash = cmd,
out = '%s-%s-features.xml' % (feature_name.split(':')[1], version),
out = 'features.xml',
visibility = [],
)
cmd = '$(exe //buck-tools:onos-app-writer) -A ' + ' '.join(args) + ' > $OUT'
......@@ -50,10 +50,10 @@ def onos_app(
)
sources = [
'$(location :app-features) %s' % feature_name,
'$(location :app-features) %s' % feature_coords,
'$(location :app-xml) NONE',
]
sources += ['$(location %s) %s' % i for i in included_bundles]
sources += ['$(location %s) $(maven_coords %s)' % (i, i) for i in included_bundles]
genrule(
name = 'app-oar',
out = 'app.oar',
......