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
Showing
6 changed files
with
22 additions
and
38 deletions
1 | - | ||
2 | BUNDLES = [ | 1 | BUNDLES = [ |
3 | - ('//apps/dhcp/api:onos-app-dhcp-api', ONOS_GROUP_ID + ':' + 'onos-app-dhcp-api' + ':' + ONOS_VERSION), | 2 | + '//apps/dhcp/api:onos-app-dhcp-api', |
4 | - ('//apps/dhcp/app:onos-app-dhcp-app', ONOS_GROUP_ID + ':' + 'onos-app-dhcp-app' + ':' + ONOS_VERSION), | 3 | + '//apps/dhcp/app:onos-app-dhcp-app', |
5 | ] | 4 | ] |
6 | 5 | ||
7 | onos_app( | 6 | onos_app( |
8 | app_name = 'org.onosproject.dhcp', | 7 | app_name = 'org.onosproject.dhcp', |
9 | - feature_name = ONOS_GROUP_ID + ':onos-app-dhcp:' + ONOS_VERSION, | 8 | + feature_coords = ONOS_GROUP_ID + ':onos-app-dhcp:' + ONOS_VERSION, |
10 | title = 'DHCP Server App', | 9 | title = 'DHCP Server App', |
11 | category = 'Utility', | 10 | category = 'Utility', |
12 | url = 'http://onosproject.org', | 11 | url = 'http://onosproject.org', | ... | ... |
1 | -SRC = 'src/main/java/org/onosproject/**/' | ||
2 | -TEST = 'src/test/java/org/onosproject/**/' | ||
3 | - | ||
4 | CURRENT_NAME = 'onos-app-fwd' | 1 | CURRENT_NAME = 'onos-app-fwd' |
5 | CURRENT_TARGET = ':' + CURRENT_NAME | 2 | CURRENT_TARGET = ':' + CURRENT_NAME |
6 | 3 | ||
... | @@ -18,27 +15,16 @@ osgi_jar( | ... | @@ -18,27 +15,16 @@ osgi_jar( |
18 | name = CURRENT_NAME, | 15 | name = CURRENT_NAME, |
19 | srcs = glob([SRC + '/*.java']), | 16 | srcs = glob([SRC + '/*.java']), |
20 | deps = COMPILE_DEPS, | 17 | deps = COMPILE_DEPS, |
18 | + test_srcs = glob([TEST + '/*.java']), | ||
19 | + test_deps = TEST_DEPS, | ||
21 | visibility = ['PUBLIC'], | 20 | visibility = ['PUBLIC'], |
22 | ) | 21 | ) |
23 | 22 | ||
24 | -java_test( | ||
25 | - name = 'tests', | ||
26 | - srcs = glob([TEST + '/*.java']), | ||
27 | - deps = COMPILE_DEPS + | ||
28 | - TEST_DEPS + | ||
29 | - [CURRENT_TARGET], | ||
30 | - source_under_test = [CURRENT_TARGET], | ||
31 | -) | ||
32 | - | ||
33 | -BUNDLES = [ | ||
34 | - (CURRENT_TARGET, ONOS_GROUP_ID + ':' + CURRENT_NAME + ':' + ONOS_VERSION), | ||
35 | -] | ||
36 | - | ||
37 | onos_app( | 23 | onos_app( |
38 | app_name = 'org.onosproject.fwd', | 24 | app_name = 'org.onosproject.fwd', |
39 | title = 'Reactive Forwarding App', | 25 | title = 'Reactive Forwarding App', |
40 | category = 'Traffic Steering', | 26 | category = 'Traffic Steering', |
41 | url = 'http://onosproject.org', | 27 | url = 'http://onosproject.org', |
42 | description = 'Reactive forwarding application using flow subsystem.', | 28 | description = 'Reactive forwarding application using flow subsystem.', |
43 | - included_bundles = BUNDLES, | 29 | + included_bundles = [ CURRENT_TARGET ], |
44 | ) | 30 | ) |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -96,7 +96,7 @@ if __name__ == '__main__': | ... | @@ -96,7 +96,7 @@ if __name__ == '__main__': |
96 | import sys, optparse | 96 | import sys, optparse |
97 | 97 | ||
98 | parser = optparse.OptionParser() | 98 | parser = optparse.OptionParser() |
99 | - parser.add_option("-n", "--name", dest="feature_name", help="Feature Name") | 99 | + parser.add_option("-n", "--name", dest="feature_coords", help="Feature MVN Coords") |
100 | parser.add_option("-a", "--app", dest="app_name", help="App Name") | 100 | parser.add_option("-a", "--app", dest="app_name", help="App Name") |
101 | parser.add_option("-o", "--origin", dest="origin", help="Origin") | 101 | parser.add_option("-o", "--origin", dest="origin", help="Origin") |
102 | parser.add_option("-c", "--category", dest="category", help="Category") | 102 | parser.add_option("-c", "--category", dest="category", help="Category") |
... | @@ -124,8 +124,8 @@ if __name__ == '__main__': | ... | @@ -124,8 +124,8 @@ if __name__ == '__main__': |
124 | (options, args) = parser.parse_args() | 124 | (options, args) = parser.parse_args() |
125 | 125 | ||
126 | values = {} | 126 | values = {} |
127 | - if options.feature_name and options.version and options.title: | 127 | + if options.feature_coords and options.version and options.title: |
128 | - values['feature_name'] = options.feature_name.split(':')[1] | 128 | + values['feature_name'] = options.feature_coords.split(':')[1] |
129 | values['version'] = options.version | 129 | values['version'] = options.version |
130 | values['title'] = options.title | 130 | values['title'] = options.title |
131 | else: | 131 | else: |
... | @@ -144,7 +144,7 @@ if __name__ == '__main__': | ... | @@ -144,7 +144,7 @@ if __name__ == '__main__': |
144 | sys.exit(1) | 144 | sys.exit(1) |
145 | 145 | ||
146 | values['feature_repo_name'] = options.repo_name if options.repo_name \ | 146 | values['feature_repo_name'] = options.repo_name if options.repo_name \ |
147 | - else options.feature_name | 147 | + else options.feature_coords |
148 | 148 | ||
149 | if options.write_features: | 149 | if options.write_features: |
150 | bundles = [] | 150 | bundles = [] | ... | ... |
... | @@ -16,8 +16,9 @@ def generateOar(output, files=[]): | ... | @@ -16,8 +16,9 @@ def generateOar(output, files=[]): |
16 | extension = filename.split('.')[-1] | 16 | extension = filename.split('.')[-1] |
17 | if extension == 'jar': | 17 | if extension == 'jar': |
18 | filename = '%s-%s.jar' % ( artifactId, version ) | 18 | filename = '%s-%s.jar' % ( artifactId, version ) |
19 | + elif 'features.xml' in filename: | ||
20 | + filename = '%s-%s-features.xml' % ( artifactId, version ) | ||
19 | dest = 'm2/%s/%s/%s/%s' % ( groupId, artifactId, version, filename ) | 21 | dest = 'm2/%s/%s/%s/%s' % ( groupId, artifactId, version, filename ) |
20 | - print file, '->', dest | ||
21 | zip.write(file, dest) | 22 | zip.write(file, dest) |
22 | 23 | ||
23 | if __name__ == '__main__': | 24 | if __name__ == '__main__': | ... | ... |
... | @@ -93,8 +93,6 @@ def osgi_jar( | ... | @@ -93,8 +93,6 @@ def osgi_jar( |
93 | visibility = visibility, | 93 | visibility = visibility, |
94 | ) | 94 | ) |
95 | 95 | ||
96 | - | ||
97 | - | ||
98 | ### Checkstyle | 96 | ### Checkstyle |
99 | chk_cmd = ' '.join(( 'java -jar $(location //lib:checkstyle)', | 97 | chk_cmd = ' '.join(( 'java -jar $(location //lib:checkstyle)', |
100 | '-o $OUT', | 98 | '-o $OUT', |
... | @@ -132,7 +130,7 @@ def osgi_jar( | ... | @@ -132,7 +130,7 @@ def osgi_jar( |
132 | if test_resources and not test_resources_root: | 130 | if test_resources and not test_resources_root: |
133 | test_resources_root = RESOURCES_ROOT | 131 | test_resources_root = RESOURCES_ROOT |
134 | 132 | ||
135 | - if test_srcs: | 133 | + if test_srcs is not None: |
136 | java_test( | 134 | java_test( |
137 | name = 'tests', | 135 | name = 'tests', |
138 | srcs = test_srcs, | 136 | srcs = test_srcs, | ... | ... |
... | @@ -11,17 +11,17 @@ def onos_app( | ... | @@ -11,17 +11,17 @@ def onos_app( |
11 | url = None, | 11 | url = None, |
12 | description = None, #TODO make this a file | 12 | description = None, #TODO make this a file |
13 | #TODO icon, | 13 | #TODO icon, |
14 | - feature_name = None, | 14 | + feature_coords = None, |
15 | required_features = [ 'onos-api' ], | 15 | required_features = [ 'onos-api' ], |
16 | required_apps = [], | 16 | required_apps = [], |
17 | included_bundles = [], | 17 | included_bundles = [], |
18 | excluded_bundles = [], | 18 | excluded_bundles = [], |
19 | **kwargs): | 19 | **kwargs): |
20 | 20 | ||
21 | - if not feature_name and len(included_bundles) == 1: | 21 | + if not feature_coords and len(included_bundles) == 1: |
22 | - feature_name = included_bundles[0][1] | 22 | + feature_coords = '$(maven_coords %s)' % included_bundles[0] |
23 | 23 | ||
24 | - args = [ '-n %s' % feature_name, | 24 | + args = [ '-n %s' % feature_coords, |
25 | '-v %s' % version, | 25 | '-v %s' % version, |
26 | '-t "%s"' % title, | 26 | '-t "%s"' % title, |
27 | '-o "%s"' % origin, | 27 | '-o "%s"' % origin, |
... | @@ -30,15 +30,15 @@ def onos_app( | ... | @@ -30,15 +30,15 @@ def onos_app( |
30 | '-u %s' % url, | 30 | '-u %s' % url, |
31 | ] | 31 | ] |
32 | args += [ '-f %s' % f for f in required_features ] | 32 | args += [ '-f %s' % f for f in required_features ] |
33 | - args += [ '-b %s' % b for (t, b) in included_bundles ] | 33 | + args += [ '-b $(maven_coords %s)' % b for b in included_bundles ] |
34 | - args += [ '-e %s' % b for (t, b) in excluded_bundles ] | 34 | + args += [ '-e $(maven_coords %s)' % b for b in excluded_bundles ] |
35 | args += [ '-d %s' % a for a in required_apps ] | 35 | args += [ '-d %s' % a for a in required_apps ] |
36 | 36 | ||
37 | cmd = '$(exe //buck-tools:onos-app-writer) -F ' + ' '.join(args) + ' > $OUT' | 37 | cmd = '$(exe //buck-tools:onos-app-writer) -F ' + ' '.join(args) + ' > $OUT' |
38 | genrule( | 38 | genrule( |
39 | name = 'app-features', | 39 | name = 'app-features', |
40 | bash = cmd, | 40 | bash = cmd, |
41 | - out = '%s-%s-features.xml' % (feature_name.split(':')[1], version), | 41 | + out = 'features.xml', |
42 | visibility = [], | 42 | visibility = [], |
43 | ) | 43 | ) |
44 | cmd = '$(exe //buck-tools:onos-app-writer) -A ' + ' '.join(args) + ' > $OUT' | 44 | cmd = '$(exe //buck-tools:onos-app-writer) -A ' + ' '.join(args) + ' > $OUT' |
... | @@ -50,10 +50,10 @@ def onos_app( | ... | @@ -50,10 +50,10 @@ def onos_app( |
50 | ) | 50 | ) |
51 | 51 | ||
52 | sources = [ | 52 | sources = [ |
53 | - '$(location :app-features) %s' % feature_name, | 53 | + '$(location :app-features) %s' % feature_coords, |
54 | '$(location :app-xml) NONE', | 54 | '$(location :app-xml) NONE', |
55 | ] | 55 | ] |
56 | - sources += ['$(location %s) %s' % i for i in included_bundles] | 56 | + sources += ['$(location %s) $(maven_coords %s)' % (i, i) for i in included_bundles] |
57 | genrule( | 57 | genrule( |
58 | name = 'app-oar', | 58 | name = 'app-oar', |
59 | out = 'app.oar', | 59 | out = 'app.oar', | ... | ... |
-
Please register or login to post a comment