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