Bazel support for apps with more than one included artifact
Change-Id: I2972772517a9b5f7f1fac52b9c00123689c0881c
diff --git a/apps/mcast/BUILD b/apps/mcast/BUILD
new file mode 100644
index 0000000..42bb7b9
--- /dev/null
+++ b/apps/mcast/BUILD
@@ -0,0 +1,15 @@
+BUNDLES = [
+ "//apps/mcast/cli:onos-apps-mcast-cli",
+ "//apps/mcast/impl:onos-apps-mcast-impl",
+ "//apps/mcast/web:onos-apps-mcast-web",
+ "//apps/mcast/api:onos-apps-mcast-api",
+]
+
+onos_app(
+ title = 'Multicast traffic control',
+ origin = 'ONF',
+ description = 'Provides handling of multicast traffic.',
+ category = 'Traffic Engineering',
+ url = 'https://wiki.onosproject.org/',
+ included_bundles = BUNDLES,
+)
diff --git a/modules.bzl b/modules.bzl
index 8ade79e..1cea8b9 100644
--- a/modules.bzl
+++ b/modules.bzl
@@ -243,7 +243,7 @@
#"//apps/rabbitmq:onos-apps-rabbitmq-oar",
#"//apps/odtn/api:onos-apps-odtn-api-oar",
#"//apps/odtn/service:onos-apps-odtn-service-oar",
- #"//apps/mcast:onos-apps-mcast-oar",
+ "//apps/mcast:onos-apps-mcast-oar",
#"//apps/layout:onos-apps-layout-oar",
#"//apps/imr:onos-apps-imr-oar",
#"//apps/nodemetrics:onos-apps-nodemetrics-oar",
diff --git a/tools/build/bazel/onos_app.bzl b/tools/build/bazel/onos_app.bzl
index 574b654..793ecc4 100644
--- a/tools/build/bazel/onos_app.bzl
+++ b/tools/build/bazel/onos_app.bzl
@@ -30,19 +30,26 @@
app_xml_file = ctx.attr.app_xml.files.to_list()[0]
feature_xml_file = ctx.attr.feature_xml.files.to_list()[0]
feature_xml_coords = ctx.attr.feature_xml_coords
- jar_file = ctx.attr.jar_file.files.to_list()[0]
+
+ jar_file_args = []
+ jar_files = []
+ for bundle in ctx.attr.included_bundles:
+ jar_file = bundle.files.to_list()[0]
+ jar_files.append(jar_file)
+ jar_file_coords = maven_coordinates(bundle.label)
+ jar_file_args.append(jar_file.path)
+ jar_file_args.append(jar_file_coords)
+
arguments = [
ctx.outputs.app_oar.path,
feature_xml_file.path,
feature_xml_coords,
app_xml_file.path,
"NONE",
- jar_file.path,
- feature_xml_coords,
- ]
+ ] + jar_file_args
ctx.actions.run(
- inputs = [app_xml_file, feature_xml_file, jar_file],
+ inputs = [app_xml_file, feature_xml_file] + jar_files,
outputs = [ctx.outputs.app_oar],
arguments = arguments,
progress_message = "Running oar file generator: %s" % ctx.attr.name,
@@ -65,6 +72,7 @@
included_bundles = ctx.attr.included_bundles
excluded_bundles = ctx.attr.excluded_bundles
required_features = ctx.attr.required_features
+ required_apps = ctx.attr.required_apps
security = ctx.attr.security
artifacts_args = []
@@ -119,7 +127,7 @@
"app_xml": attr.label(),
"feature_xml": attr.label(),
"feature_xml_coords": attr.string(),
- "jar_file": attr.label(),
+ "included_bundles": attr.label_list(),
"_onos_app_oar_exe": attr.label(
executable = True,
cfg = "host",
@@ -150,6 +158,7 @@
"required_features": attr.string_list(),
"security": attr.string(),
"mode": attr.string(),
+ "required_apps": attr.string_list(),
"_onos_app_writer_exe": attr.label(
executable = True,
cfg = "host",
@@ -180,6 +189,7 @@
"required_features": attr.string_list(),
"security": attr.string(),
"mode": attr.string(),
+ "required_apps": attr.string_list(),
"_onos_app_writer_exe": attr.label(
executable = True,
cfg = "host",
@@ -244,7 +254,7 @@
title = _get_app_name()
if included_bundles == None:
- target = ":" + name
+ target = _local_label(name, "")
included_bundles = [target]
# TODO - have to implement this eventually
@@ -271,6 +281,7 @@
apps = apps,
included_bundles = included_bundles,
excluded_bundles = excluded_bundles,
+ required_apps = required_apps,
mode = "-A",
)
@@ -296,7 +307,7 @@
# rule to generate the OAR file based on the app.xml, features.xml, and app jar file
_onos_oar(
name = name + "-oar",
- jar_file = Label(_local_label(name, "")),
+ included_bundles = included_bundles,
app_xml = Label(_local_label(name, "-app-xml")),
feature_xml = Label(_local_label(name, "-feature-xml")),
feature_xml_coords = feature_xml_coords,
diff --git a/tools/build/bazel/onos_oar.py b/tools/build/bazel/onos_oar.py
index 4a82b62..e5915f8 100755
--- a/tools/build/bazel/onos_oar.py
+++ b/tools/build/bazel/onos_oar.py
@@ -1,12 +1,14 @@
#!/usr/bin/env python
#FIXME Add license
-from zipfile import ZipFile
+from zipfile import ZipFile, ZipInfo
+import os
def generateOar(output, files=[]):
# Note this is not a compressed zip
with ZipFile(output, 'w') as zip:
for file, mvnCoords in files:
+ mvnCoords = mvnCoords.replace("mvn:", "")
filename = file.split('/')[-1]
if mvnCoords == 'NONE':
if 'app-xml.xml' in filename:
@@ -25,7 +27,9 @@
elif 'feature-xml' in filename:
filename = '%s-%s-features.xml' % ( artifactId, version )
dest = 'm2/%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