blob: 6480e3fde42e192f9ca5b6282ce76abb7dce43c7 [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 {
28 bazel build $* --aspects tools/build/bazel/publish_catalog.bzl%publish_catalog 2>&1 \
Thomas Vachuska74d28d82018-08-09 15:40:43 -070029 | egrep "^DEBUG: .*/publish_catalog.bzl:" | cut -d\ -f3- >> $CATALOG
Thomas Vachuska2988e142018-07-23 16:20:01 -070030}
31
32function jars {
Ray Milkey549b1542019-04-18 11:44:50 -070033 egrep -v '(\#|build/conf)' tools/build/publish-target-list
Thomas Vachuska2988e142018-07-23 16:20:01 -070034}
35
Carmelo Casconec0b23a42019-04-25 13:50:54 -070036function sourceJars {
37 egrep -v '(\#|lib\:|p4runtime/proto|build/conf)' tools/build/publish-target-list
38}
39
40function javadocJars {
41 egrep -v '(\#|lib\:|p4runtime/proto|build/conf)' tools/build/publish-target-list
42}
43
Thomas Vachuska2988e142018-07-23 16:20:01 -070044function testJars {
Ray Milkey549b1542019-04-18 11:44:50 -070045 egrep -v '(\#|build/conf)' tools/build/publish-test-target-list
Thomas Vachuska2988e142018-07-23 16:20:01 -070046}
47
Thomas Vachuskad82635b2018-08-20 11:35:11 -070048echo "Cataloging jar files..."
49writeCatalog $(jars)
50
51echo "Cataloging test jars..."
52writeCatalog $(testJars)
53
Ray Milkey246594e2019-04-25 12:58:05 -070054echo "Cataloging pom files..."
55writeCatalog $(jars | sed 's/$/-pom/')
56
Thomas Vachuskad82635b2018-08-20 11:35:11 -070057[ $libsOnly = true ] && exit 0
58
59echo "Cataloging source jars..."
Carmelo Casconec0b23a42019-04-25 13:50:54 -070060writeCatalog $(sourceJars | sed 's/$/-sources/')
Thomas Vachuskad82635b2018-08-20 11:35:11 -070061echo "Cataloging javadoc jars..."
Carmelo Casconec0b23a42019-04-25 13:50:54 -070062writeCatalog $(javadocJars | sed 's/$/-javadoc/')
Thomas Vachuskad82635b2018-08-20 11:35:11 -070063
64echo "Cataloging oar files..."
65writeCatalog $(bazel query 'kind("_onos_oar rule", //...)')
66
Thomas Vachuskac5348122018-08-08 17:48:45 -070067# Extract the version from the Bazel variables file
Thomas Vachuskab9697692018-07-30 13:33:29 -070068VERSION=$(egrep ONOS_VERSION tools/build/bazel/variables.bzl | cut -d\" -f2)
Thomas Vachuskac5348122018-08-08 17:48:45 -070069
70# Inject the onos-dependencies pom, ONOS tar, admin tar and test tar.
71echo "Cataloging tar files..."
72cat >> $CATALOG <<EOF
73lib/pom.xml org/onosproject/onos-dependencies/$VERSION/onos-dependencies-$VERSION.pom
74bazel-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