Fixing Maven coordinates for Bazel and adding feature artifact bundle.
Change-Id: Ic6a3120e5316afa2c394a1c904cf848bb7ed3c76
diff --git a/lib/BUCK b/lib/BUCK
index 938759f..2515198 100644
--- a/lib/BUCK
+++ b/lib/BUCK
@@ -1,4 +1,4 @@
-# ***** This file was auto-generated at Mon, 11 Jun 2018 23:55:52 GMT. Do not edit this file manually. *****
+# ***** This file was auto-generated at Tue, 12 Jun 2018 23:00:36 GMT. Do not edit this file manually. *****
# ***** Use onos-lib-gen *****
pass_thru_pom(
diff --git a/tools/build/bazel/generate_workspace.bzl b/tools/build/bazel/generate_workspace.bzl
index b0328a7..ca13bb3 100644
--- a/tools/build/bazel/generate_workspace.bzl
+++ b/tools/build/bazel/generate_workspace.bzl
@@ -1,4 +1,4 @@
-# ***** This file was auto-generated at Mon, 11 Jun 2018 23:55:58 GMT. Do not edit this file manually. *****
+# ***** This file was auto-generated at Tue, 12 Jun 2018 23:00:43 GMT. Do not edit this file manually. *****
# ***** Use onos-lib-gen *****
load("//tools/build/bazel:variables.bzl", "ONOS_GROUP_ID", "ONOS_VERSION")
@@ -2267,4 +2267,4 @@
if label_string in artifact_map:
return artifact_map[label_string]
else:
- return "%s:%s:%s" % (ONOS_GROUP_ID, label.name, ONOS_VERSION)
+ return "mvn:%s:%s:%s" % (ONOS_GROUP_ID, label.name, ONOS_VERSION)
diff --git a/tools/build/bazel/onos_feature.py b/tools/build/bazel/onos_feature.py
index 731ce71..368d281 100755
--- a/tools/build/bazel/onos_feature.py
+++ b/tools/build/bazel/onos_feature.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
#FIXME Add license
-from zipfile import ZipFile
+from zipfile import ZipFile, ZipInfo
def generateOar(output, files=[]):
# Note this is not a compressed zip
@@ -12,9 +12,9 @@
dest = filename
else:
parts = mvnCoords.split(':')
- if len(parts) > 3:
- parts.insert(2, parts.pop()) # move version to the 3rd position
- groupId, artifactId, version = parts[0:3]
+ if len(parts) > 4:
+ parts.insert(3, parts.pop()) # move version to the 3rd position
+ groupId, artifactId, version = parts[1:4]
groupId = groupId.replace('.', '/')
extension = filename.split('.')[-1]
if extension == 'jar':
@@ -22,7 +22,9 @@
elif 'features.xml' in filename:
filename = '%s-%s-features.xml' % ( artifactId, version )
dest = '%s/%s/%s/%s' % ( groupId, artifactId, version, filename )
- zip.write(file, dest)
+ f = open(file, 'rb')
+ zip.writestr(ZipInfo(dest, date_time=(1980, 1, 1, 0, 0, 0)), f.read())
+ f.close()
if __name__ == '__main__':
import sys
diff --git a/tools/build/bazel/osgi_features.bzl b/tools/build/bazel/osgi_features.bzl
index 613bf7b..9683789 100644
--- a/tools/build/bazel/osgi_features.bzl
+++ b/tools/build/bazel/osgi_features.bzl
@@ -23,45 +23,48 @@
# Implementation of a rule to produce an OSGi feature XML snippet
def _osgi_feature_impl(ctx):
- output = ctx.outputs.feature_xml
-
- args = [
- "-O",
- output.path,
- "-n",
- ctx.attr.name,
- "-v",
- ctx.attr.version,
- "-t",
- ctx.attr.description,
+ xmlArgs = [
+ "-O", ctx.outputs.feature_xml.path,
+ "-n", ctx.attr.name,
+ "-v", ctx.attr.version,
+ "-t", ctx.attr.description,
]
-
+ bundleArgs = [ctx.outputs.bundle_zip.path]
inputs = []
+
for dep in ctx.attr.included_bundles:
- args += ["-b", maven_coordinates(dep.label)]
+ coord = maven_coordinates(dep.label)
+ xmlArgs += ["-b", coord]
+ if java_common.provider in dep:
+ inputs += [dep.files.to_list()[0]]
+ bundleArgs += [dep.files.to_list()[0].path, coord]
- for f in ctx.attr.included_bundles:
- if java_common.provider in f:
- inputs += [f.files.to_list()[0]]
-
- for f in ctx.attr.excluded_bundles:
- args += ["-e", maven_coordinates(dep.label)]
- if java_common.provider in f:
- inputs += [f.files.to_list()[0]]
+ for f in ctx.attr.excluded_bundles:
+ xmlArgs += ["-e", maven_coordinates(dep.label)]
+ if java_common.provider in f:
+ inputs += [f.files.to_list()[0]]
for f in ctx.attr.required_features:
- args += ["-f", f]
+ xmlArgs += ["-f", f]
- args += ["-F" if ctx.attr.generate_file else "-E"]
+ xmlArgs += ["-F" if ctx.attr.generate_file else "-E"]
ctx.actions.run(
inputs = inputs,
- outputs = [output],
- arguments = args,
- progress_message = "Generating feature %s" % ctx.attr.name,
+ outputs = [ctx.outputs.feature_xml],
+ arguments = xmlArgs,
+ progress_message = "Generating feature %s XML" % ctx.attr.name,
executable = ctx.executable._writer,
)
+ ctx.actions.run(
+ inputs = inputs,
+ outputs = [ctx.outputs.bundle_zip],
+ arguments = bundleArgs,
+ progress_message = "Generating feature %s bundle" % ctx.attr.name,
+ executable = ctx.executable._bundler,
+ )
+
osgi_feature = rule(
attrs = {
"description": attr.string(),
@@ -76,9 +79,16 @@
allow_files = True,
default = Label("//tools/build/bazel:onos_app_writer"),
),
+ "_bundler": attr.label(
+ executable = True,
+ cfg = "host",
+ allow_files = True,
+ default = Label("//tools/build/bazel:onos_feature"),
+ ),
},
outputs = {
"feature_xml": "feature-%{name}.xml",
+ "bundle_zip": "feature-%{name}.zip",
},
implementation = _osgi_feature_impl,
)
diff --git a/tools/build/libgen/src/main/java/org/onosproject/libgen/BuckLibGenerator.java b/tools/build/libgen/src/main/java/org/onosproject/libgen/BuckLibGenerator.java
index 5496915..82ca1cc 100644
--- a/tools/build/libgen/src/main/java/org/onosproject/libgen/BuckLibGenerator.java
+++ b/tools/build/libgen/src/main/java/org/onosproject/libgen/BuckLibGenerator.java
@@ -211,7 +211,7 @@
" if label_string in artifact_map:\n" +
" return artifact_map[label_string]\n" +
" else:\n" +
- " return \"%s:%s:%s\" % (ONOS_GROUP_ID, label.name, ONOS_VERSION)\n");
+ " return \"mvn:%s:%s:%s\" % (ONOS_GROUP_ID, label.name, ONOS_VERSION)\n");
return artifactMap.toString();
}