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