mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-17 10:21:52 +02:00
Fixing Maven coordinates for Bazel and adding feature artifact bundle.
Change-Id: Ic6a3120e5316afa2c394a1c904cf848bb7ed3c76
This commit is contained in:
parent
f25c248723
commit
e8f06893f7
2
lib/BUCK
2
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(
|
||||
|
@ -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 @@ def maven_coordinates(label):
|
||||
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)
|
||||
|
@ -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 @@ def generateOar(output, files=[]):
|
||||
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 @@ def generateOar(output, files=[]):
|
||||
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
|
||||
|
@ -23,45 +23,48 @@ def dump(obj):
|
||||
|
||||
# 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 @@ osgi_feature = rule(
|
||||
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,
|
||||
)
|
||||
|
@ -211,7 +211,7 @@ public class BuckLibGenerator {
|
||||
" 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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user