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 { |
| 28 | bazel build $* --aspects tools/build/bazel/publish_catalog.bzl%publish_catalog 2>&1 \ |
Thomas Vachuska | 74d28d8 | 2018-08-09 15:40:43 -0700 | [diff] [blame] | 29 | | egrep "^DEBUG: .*/publish_catalog.bzl:" | cut -d\ -f3- >> $CATALOG |
Thomas Vachuska | 2988e14 | 2018-07-23 16:20:01 -0700 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | function jars { |
| 33 | egrep -v '(\# |grpc/api|build/conf)' tools/build/publish-target-list |
| 34 | } |
| 35 | |
| 36 | function testJars { |
| 37 | egrep -v '(# |grpc/api|build/conf)' tools/build/publish-test-target-list |
| 38 | } |
| 39 | |
Thomas Vachuska | d82635b | 2018-08-20 11:35:11 -0700 | [diff] [blame^] | 40 | echo "Cataloging jar files..." |
| 41 | writeCatalog $(jars) |
| 42 | |
| 43 | echo "Cataloging test jars..." |
| 44 | writeCatalog $(testJars) |
| 45 | |
| 46 | [ $libsOnly = true ] && exit 0 |
| 47 | |
| 48 | echo "Cataloging source jars..." |
| 49 | writeCatalog $(jars | sed 's/$/-sources/') |
| 50 | echo "Cataloging javadoc jars..." |
| 51 | writeCatalog $(jars | sed 's/$/-javadoc/') |
| 52 | echo "Cataloging pom files..." |
| 53 | writeCatalog $(jars | sed 's/$/-pom/') |
| 54 | |
| 55 | echo "Cataloging oar files..." |
| 56 | writeCatalog $(bazel query 'kind("_onos_oar rule", //...)') |
| 57 | |
Thomas Vachuska | c534812 | 2018-08-08 17:48:45 -0700 | [diff] [blame] | 58 | # Extract the version from the Bazel variables file |
Thomas Vachuska | b969769 | 2018-07-30 13:33:29 -0700 | [diff] [blame] | 59 | VERSION=$(egrep ONOS_VERSION tools/build/bazel/variables.bzl | cut -d\" -f2) |
Thomas Vachuska | c534812 | 2018-08-08 17:48:45 -0700 | [diff] [blame] | 60 | |
| 61 | # Inject the onos-dependencies pom, ONOS tar, admin tar and test tar. |
| 62 | echo "Cataloging tar files..." |
| 63 | cat >> $CATALOG <<EOF |
| 64 | lib/pom.xml org/onosproject/onos-dependencies/$VERSION/onos-dependencies-$VERSION.pom |
| 65 | bazel-bin/onos.tar.gz org/onosproject/onos-releases/$VERSION/onos-$VERSION.tar.gz |
| 66 | bazel-bin/onos-admin.tar.gz org/onosproject/onos-releases/$VERSION/onos-admin-$VERSION.tar.gz |
| 67 | 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] | 68 | 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] | 69 | EOF |