blob: 595c74e411e6d8e8fa415b7a61c6f7a26eeff572 [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
Thomas Vachuskad82635b2018-08-20 11:35:11 -07006libsOnly=false
7
8# Process any usage options
9while getopts lh? o; do
10 case "$o" in
11 l) libsOnly=true;;
12 *) echo "usage: $(basename $0) [-l]" >&2; exit 1;;
13 esac
14done
15let OPC=$OPTIND-1
16shift $OPC
17
Ray Milkey7f46b1f2018-07-24 19:01:58 -070018set -e -o pipefail
19
Thomas Vachuska22a662b2018-07-24 11:25:19 -070020CATALOG=${1:-/tmp/onos.catalog}
Thomas Vachuska2988e142018-07-23 16:20:01 -070021
22rm -f $CATALOG
23
Thomas Vachuskac5348122018-08-08 17:48:45 -070024# Required to avoid having Bazel re-build stuff unnecessarily
25export SHLVL=1
Thomas Vachuska2988e142018-07-23 16:20:01 -070026
27function writeCatalog {
Ray Milkey69b2fed2019-04-26 09:50:20 -070028 if ! bazel build $* --aspects tools/build/bazel/publish_catalog.bzl%publish_catalog >/tmp/onos.catalog.bazel.out 2>&1; then
29 echo Bazel build of catalog failed
30 cat /tmp/onos.catalog.bazel.out
31 exit 1
32 fi
33
34 egrep "^DEBUG: .*/publish_catalog.bzl:" /tmp/onos.catalog.bazel.out | cut -d\ -f3- >> $CATALOG
Thomas Vachuska2988e142018-07-23 16:20:01 -070035}
36
37function jars {
Carmelo Cascone27b97122019-11-12 10:34:05 -080038 egrep -v '(\#)' tools/build/publish-target-list
Thomas Vachuska2988e142018-07-23 16:20:01 -070039}
40
41function testJars {
Carmelo Cascone27b97122019-11-12 10:34:05 -080042 egrep -v '(\#)' tools/build/publish-test-target-list
43}
44
45function sources {
46 egrep -v '(\#|build/conf|dependencies)' tools/build/publish-target-list
Thomas Vachuska2988e142018-07-23 16:20:01 -070047}
48
Thomas Vachuskad82635b2018-08-20 11:35:11 -070049echo "Cataloging jar files..."
50writeCatalog $(jars)
51
52echo "Cataloging test jars..."
53writeCatalog $(testJars)
54
Ray Milkey246594e2019-04-25 12:58:05 -070055echo "Cataloging pom files..."
56writeCatalog $(jars | sed 's/$/-pom/')
57
Thomas Vachuskad82635b2018-08-20 11:35:11 -070058[ $libsOnly = true ] && exit 0
59
60echo "Cataloging source jars..."
Carmelo Cascone27b97122019-11-12 10:34:05 -080061writeCatalog $(sources | sed 's/$/-sources/')
Thomas Vachuskad82635b2018-08-20 11:35:11 -070062echo "Cataloging javadoc jars..."
Carmelo Cascone27b97122019-11-12 10:34:05 -080063writeCatalog $(sources | sed 's/$/-javadoc/')
Thomas Vachuskad82635b2018-08-20 11:35:11 -070064
65echo "Cataloging oar files..."
66writeCatalog $(bazel query 'kind("_onos_oar rule", //...)')
67
Thomas Vachuskac5348122018-08-08 17:48:45 -070068# Extract the version from the Bazel variables file
Thomas Vachuskab9697692018-07-30 13:33:29 -070069VERSION=$(egrep ONOS_VERSION tools/build/bazel/variables.bzl | cut -d\" -f2)
Thomas Vachuskac5348122018-08-08 17:48:45 -070070
71# Inject the onos-dependencies pom, ONOS tar, admin tar and test tar.
72echo "Cataloging tar files..."
73cat >> $CATALOG <<EOF
Thomas Vachuskac5348122018-08-08 17:48:45 -070074bazel-bin/onos.tar.gz org/onosproject/onos-releases/$VERSION/onos-$VERSION.tar.gz
75bazel-bin/onos-admin.tar.gz org/onosproject/onos-releases/$VERSION/onos-admin-$VERSION.tar.gz
76bazel-bin/onos-test.tar.gz org/onosproject/onos-releases/$VERSION/onos-test-$VERSION.tar.gz
Ray Milkey591f66a2018-08-14 14:20:34 -070077bazel-bin/tools/build/conf/libonos-build-conf.jar org/onosproject/onos-build-conf/$VERSION/onos-build-conf-$VERSION.jar
Thomas Vachuskac5348122018-08-08 17:48:45 -070078EOF