bucklet for yang based OSGI libraries
Change-Id: Ieeef6357250c4e74e9c78310a65c809b3edd102b
diff --git a/bucklets/yang.bucklet b/bucklets/yang.bucklet
new file mode 100644
index 0000000..9c15a51
--- /dev/null
+++ b/bucklets/yang.bucklet
@@ -0,0 +1,51 @@
+include_defs('//onos.defs')
+
+def _get_name():
+ base_path = get_base_path()
+ return ONOS_ARTIFACT_BASE + base_path.replace('/', '-') #TODO Unix-separator
+
+def yang_osgi_jar(
+ name = None,
+ srcs = None,
+ group_id = ONOS_GROUP_ID,
+ version = ONOS_VERSION,
+ deps = [],
+ visibility = ['PUBLIC'],
+ license = 'NONE',
+ **kwargs
+ ):
+
+ if name is None:
+ name = _get_name()
+
+ yang_jar = name + '-yang'
+ bnd_jar = name + '-bnd'
+
+ args = { 'group':group_id, 'artifact':name, 'version':version }
+
+ yang_library(
+ deps = deps,
+ name = yang_jar,
+ srcs = srcs,
+ visibility = [ ],
+ )
+
+ cmd = 'java -jar $(location //lib:bndexe) wrap -o $OUT '
+ cmd += '-b %(group)s.%(artifact)s ' % args
+ cmd += '-v ' + version.replace('-', '.') + ' '
+ cmd += '$(location :%s) ' % yang_jar
+ cmd += ' >/dev/null 2>&1'
+
+ genrule(
+ name = bnd_jar,
+ bash = cmd,
+ out = name + '.jar',
+ visibility = [],
+ )
+
+ prebuilt_jar(
+ name = name,
+ binary_jar = ':' + bnd_jar,
+ maven_coords = '%(group)s:%(artifact)s:%(version)s'%args,
+ visibility = visibility,
+ )