blob: c84dde531a934adb7e0345d92d4fa18bc8ad2c2d [file] [log] [blame]
Thomas Vachuska2988e142018-07-23 16:20:01 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Generates a catalog for publishing ONOS artifacts to a Maven repository.
4# -----------------------------------------------------------------------------
5
Ray Milkey7f46b1f2018-07-24 19:01:58 -07006set -e -o pipefail
7
Thomas Vachuska22a662b2018-07-24 11:25:19 -07008CATALOG=${1:-/tmp/onos.catalog}
Thomas Vachuska2988e142018-07-23 16:20:01 -07009
10rm -f $CATALOG
11
Thomas Vachuskac5348122018-08-08 17:48:45 -070012# Required to avoid having Bazel re-build stuff unnecessarily
13export SHLVL=1
Thomas Vachuska2988e142018-07-23 16:20:01 -070014
15function writeCatalog {
16 bazel build $* --aspects tools/build/bazel/publish_catalog.bzl%publish_catalog 2>&1 \
Thomas Vachuska74d28d82018-08-09 15:40:43 -070017 | egrep "^DEBUG: .*/publish_catalog.bzl:" | cut -d\ -f3- >> $CATALOG
Thomas Vachuska2988e142018-07-23 16:20:01 -070018}
19
20function jars {
21 egrep -v '(\# |grpc/api|build/conf)' tools/build/publish-target-list
22}
23
24function testJars {
25 egrep -v '(# |grpc/api|build/conf)' tools/build/publish-test-target-list
26}
27
Thomas Vachuskac5348122018-08-08 17:48:45 -070028# Extract the version from the Bazel variables file
Thomas Vachuskab9697692018-07-30 13:33:29 -070029VERSION=$(egrep ONOS_VERSION tools/build/bazel/variables.bzl | cut -d\" -f2)
Thomas Vachuskac5348122018-08-08 17:48:45 -070030
31# Inject the onos-dependencies pom, ONOS tar, admin tar and test tar.
32echo "Cataloging tar files..."
33cat >> $CATALOG <<EOF
34lib/pom.xml org/onosproject/onos-dependencies/$VERSION/onos-dependencies-$VERSION.pom
35bazel-bin/onos.tar.gz org/onosproject/onos-releases/$VERSION/onos-$VERSION.tar.gz
36bazel-bin/onos-admin.tar.gz org/onosproject/onos-releases/$VERSION/onos-admin-$VERSION.tar.gz
37bazel-bin/onos-test.tar.gz org/onosproject/onos-releases/$VERSION/onos-test-$VERSION.tar.gz
Thomas Vachuska5538d9e2018-08-14 09:59:35 -070038bazel-bin/tools/build/conf/libonos-build-conf.jar org/onosproject/onos-build-conf/$VERSION/onos-build-conf-$VERSION.tar.gz
Thomas Vachuskac5348122018-08-08 17:48:45 -070039EOF
Thomas Vachuska2988e142018-07-23 16:20:01 -070040
41echo "Cataloging jar files..."
42writeCatalog $(jars)
43
44echo "Cataloging test jars..."
45writeCatalog $(testJars)
46
47echo "Cataloging source jars..."
48writeCatalog $(jars | sed 's/$/-sources/')
49echo "Cataloging javadoc jars..."
50writeCatalog $(jars | sed 's/$/-javadoc/')
51echo "Cataloging pom files..."
52writeCatalog $(jars | sed 's/$/-pom/')
53
54echo "Cataloging oar files..."
55writeCatalog $(bazel query 'kind("_onos_oar rule", //...)')