Thomas Vachuska | 2988e14 | 2018-07-23 16:20:01 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Generates a catalog for publishing ONOS artifacts to a Maven repository. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
Thomas Vachuska | d82635b | 2018-08-20 11:35:11 -0700 | [diff] [blame] | 6 | libsOnly=false |
| 7 | |
| 8 | # Process any usage options |
| 9 | while getopts lh? o; do |
| 10 | case "$o" in |
| 11 | l) libsOnly=true;; |
| 12 | *) echo "usage: $(basename $0) [-l]" >&2; exit 1;; |
| 13 | esac |
| 14 | done |
| 15 | let OPC=$OPTIND-1 |
| 16 | shift $OPC |
| 17 | |
Ray Milkey | 7f46b1f | 2018-07-24 19:01:58 -0700 | [diff] [blame] | 18 | set -e -o pipefail |
| 19 | |
Thomas Vachuska | 22a662b | 2018-07-24 11:25:19 -0700 | [diff] [blame] | 20 | CATALOG=${1:-/tmp/onos.catalog} |
Thomas Vachuska | 2988e14 | 2018-07-23 16:20:01 -0700 | [diff] [blame] | 21 | |
| 22 | rm -f $CATALOG |
| 23 | |
Thomas Vachuska | c534812 | 2018-08-08 17:48:45 -0700 | [diff] [blame] | 24 | # Required to avoid having Bazel re-build stuff unnecessarily |
| 25 | export SHLVL=1 |
Thomas Vachuska | 2988e14 | 2018-07-23 16:20:01 -0700 | [diff] [blame] | 26 | |
| 27 | function writeCatalog { |
Ray Milkey | 69b2fed | 2019-04-26 09:50:20 -0700 | [diff] [blame] | 28 | 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 Vachuska | 2988e14 | 2018-07-23 16:20:01 -0700 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | function jars { |
Carmelo Cascone | 27b9712 | 2019-11-12 10:34:05 -0800 | [diff] [blame^] | 38 | egrep -v '(\#)' tools/build/publish-target-list |
Thomas Vachuska | 2988e14 | 2018-07-23 16:20:01 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | function testJars { |
Carmelo Cascone | 27b9712 | 2019-11-12 10:34:05 -0800 | [diff] [blame^] | 42 | egrep -v '(\#)' tools/build/publish-test-target-list |
| 43 | } |
| 44 | |
| 45 | function sources { |
| 46 | egrep -v '(\#|build/conf|dependencies)' tools/build/publish-target-list |
Thomas Vachuska | 2988e14 | 2018-07-23 16:20:01 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Thomas Vachuska | d82635b | 2018-08-20 11:35:11 -0700 | [diff] [blame] | 49 | echo "Cataloging jar files..." |
| 50 | writeCatalog $(jars) |
| 51 | |
| 52 | echo "Cataloging test jars..." |
| 53 | writeCatalog $(testJars) |
| 54 | |
Ray Milkey | 246594e | 2019-04-25 12:58:05 -0700 | [diff] [blame] | 55 | echo "Cataloging pom files..." |
| 56 | writeCatalog $(jars | sed 's/$/-pom/') |
| 57 | |
Thomas Vachuska | d82635b | 2018-08-20 11:35:11 -0700 | [diff] [blame] | 58 | [ $libsOnly = true ] && exit 0 |
| 59 | |
| 60 | echo "Cataloging source jars..." |
Carmelo Cascone | 27b9712 | 2019-11-12 10:34:05 -0800 | [diff] [blame^] | 61 | writeCatalog $(sources | sed 's/$/-sources/') |
Thomas Vachuska | d82635b | 2018-08-20 11:35:11 -0700 | [diff] [blame] | 62 | echo "Cataloging javadoc jars..." |
Carmelo Cascone | 27b9712 | 2019-11-12 10:34:05 -0800 | [diff] [blame^] | 63 | writeCatalog $(sources | sed 's/$/-javadoc/') |
Thomas Vachuska | d82635b | 2018-08-20 11:35:11 -0700 | [diff] [blame] | 64 | |
| 65 | echo "Cataloging oar files..." |
| 66 | writeCatalog $(bazel query 'kind("_onos_oar rule", //...)') |
| 67 | |
Thomas Vachuska | c534812 | 2018-08-08 17:48:45 -0700 | [diff] [blame] | 68 | # Extract the version from the Bazel variables file |
Thomas Vachuska | b969769 | 2018-07-30 13:33:29 -0700 | [diff] [blame] | 69 | VERSION=$(egrep ONOS_VERSION tools/build/bazel/variables.bzl | cut -d\" -f2) |
Thomas Vachuska | c534812 | 2018-08-08 17:48:45 -0700 | [diff] [blame] | 70 | |
| 71 | # Inject the onos-dependencies pom, ONOS tar, admin tar and test tar. |
| 72 | echo "Cataloging tar files..." |
| 73 | cat >> $CATALOG <<EOF |
Thomas Vachuska | c534812 | 2018-08-08 17:48:45 -0700 | [diff] [blame] | 74 | bazel-bin/onos.tar.gz org/onosproject/onos-releases/$VERSION/onos-$VERSION.tar.gz |
| 75 | bazel-bin/onos-admin.tar.gz org/onosproject/onos-releases/$VERSION/onos-admin-$VERSION.tar.gz |
| 76 | bazel-bin/onos-test.tar.gz org/onosproject/onos-releases/$VERSION/onos-test-$VERSION.tar.gz |
Ray Milkey | 591f66a | 2018-08-14 14:20:34 -0700 | [diff] [blame] | 77 | bazel-bin/tools/build/conf/libonos-build-conf.jar org/onosproject/onos-build-conf/$VERSION/onos-build-conf-$VERSION.jar |
Thomas Vachuska | c534812 | 2018-08-08 17:48:45 -0700 | [diff] [blame] | 78 | EOF |