blob: ed2970f6440b73a747b02f12670994dc18b0f55f [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
38EOF
Thomas Vachuska2988e142018-07-23 16:20:01 -070039
40echo "Cataloging jar files..."
41writeCatalog $(jars)
42
43echo "Cataloging test jars..."
44writeCatalog $(testJars)
45
46echo "Cataloging source jars..."
47writeCatalog $(jars | sed 's/$/-sources/')
48echo "Cataloging javadoc jars..."
49writeCatalog $(jars | sed 's/$/-javadoc/')
50echo "Cataloging pom files..."
51writeCatalog $(jars | sed 's/$/-pom/')
52
53echo "Cataloging oar files..."
54writeCatalog $(bazel query 'kind("_onos_oar rule", //...)')