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 { |
Ray Milkey | 549b154 | 2019-04-18 11:44:50 -0700 | [diff] [blame] | 38 | egrep -v '(\#|build/conf)' tools/build/publish-target-list |
Thomas Vachuska | 2988e14 | 2018-07-23 16:20:01 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | function testJars { |
Ray Milkey | 549b154 | 2019-04-18 11:44:50 -0700 | [diff] [blame] | 42 | egrep -v '(\#|build/conf)' tools/build/publish-test-target-list |
Thomas Vachuska | 2988e14 | 2018-07-23 16:20:01 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Thomas Vachuska | d82635b | 2018-08-20 11:35:11 -0700 | [diff] [blame] | 45 | echo "Cataloging jar files..." |
| 46 | writeCatalog $(jars) |
| 47 | |
| 48 | echo "Cataloging test jars..." |
| 49 | writeCatalog $(testJars) |
| 50 | |
Ray Milkey | 246594e | 2019-04-25 12:58:05 -0700 | [diff] [blame] | 51 | echo "Cataloging pom files..." |
| 52 | writeCatalog $(jars | sed 's/$/-pom/') |
| 53 | |
Thomas Vachuska | d82635b | 2018-08-20 11:35:11 -0700 | [diff] [blame] | 54 | [ $libsOnly = true ] && exit 0 |
| 55 | |
| 56 | echo "Cataloging source jars..." |
Ray Milkey | 522a3bd | 2019-04-25 17:32:57 -0700 | [diff] [blame] | 57 | writeCatalog $(jars | sed 's/$/-sources/') |
Thomas Vachuska | d82635b | 2018-08-20 11:35:11 -0700 | [diff] [blame] | 58 | echo "Cataloging javadoc jars..." |
Ray Milkey | 522a3bd | 2019-04-25 17:32:57 -0700 | [diff] [blame] | 59 | writeCatalog $(jars | sed 's/$/-javadoc/') |
Thomas Vachuska | d82635b | 2018-08-20 11:35:11 -0700 | [diff] [blame] | 60 | |
| 61 | echo "Cataloging oar files..." |
| 62 | writeCatalog $(bazel query 'kind("_onos_oar rule", //...)') |
| 63 | |
Thomas Vachuska | c534812 | 2018-08-08 17:48:45 -0700 | [diff] [blame] | 64 | # Extract the version from the Bazel variables file |
Thomas Vachuska | b969769 | 2018-07-30 13:33:29 -0700 | [diff] [blame] | 65 | VERSION=$(egrep ONOS_VERSION tools/build/bazel/variables.bzl | cut -d\" -f2) |
Thomas Vachuska | c534812 | 2018-08-08 17:48:45 -0700 | [diff] [blame] | 66 | |
| 67 | # Inject the onos-dependencies pom, ONOS tar, admin tar and test tar. |
| 68 | echo "Cataloging tar files..." |
| 69 | cat >> $CATALOG <<EOF |
| 70 | lib/pom.xml org/onosproject/onos-dependencies/$VERSION/onos-dependencies-$VERSION.pom |
| 71 | bazel-bin/onos.tar.gz org/onosproject/onos-releases/$VERSION/onos-$VERSION.tar.gz |
| 72 | bazel-bin/onos-admin.tar.gz org/onosproject/onos-releases/$VERSION/onos-admin-$VERSION.tar.gz |
| 73 | 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] | 74 | 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] | 75 | EOF |