Thomas Vachuska | 692dcb0 | 2017-03-15 09:13:50 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Patches lib/BUCK file to use locally built YANG tools. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
Ray Milkey | 5193cb7 | 2018-02-09 11:21:32 -0800 | [diff] [blame] | 6 | BVER=2.4 |
| 7 | SVER=2.5-SNAPSHOT |
Thomas Vachuska | 692dcb0 | 2017-03-15 09:13:50 -0700 | [diff] [blame] | 8 | |
Yuta HIGUCHI | 4421dd2 | 2017-08-10 18:08:37 -0700 | [diff] [blame] | 9 | YANG_TOOLS_ROOT=${YANG_TOOLS_ROOT:-~/onos-yang-tools} |
Thomas Vachuska | 692dcb0 | 2017-03-15 09:13:50 -0700 | [diff] [blame] | 10 | |
| 11 | rm -f $ONOS_ROOT/lib/yang/* 2>/dev/null |
| 12 | mkdir -p $ONOS_ROOT/lib/yang |
| 13 | |
| 14 | awk ' |
| 15 | BEGIN { m = 0; y = 0; } |
| 16 | /^(remote_jar|prebuilt_jar)/ { s = $0; m = 1; next; } |
| 17 | { if (m) { s = s "\n" $0; } else { print $0; } } |
| 18 | /onos-yang-.*('$BVER'|'$SVER')/ { y = 1; } |
| 19 | /^\)/ { if (m && !y) { print s; } y = 0; m = 0; } |
| 20 | ' $ONOS_ROOT/lib/BUCK > /tmp/BUCK |
| 21 | mv /tmp/BUCK $ONOS_ROOT/lib/BUCK |
| 22 | |
| 23 | for yl in $(egrep "onos-yang-.*$BVER" $ONOS_ROOT/lib/deps.json); do |
| 24 | n=$(echo $yl | cut -d\" -f2) |
| 25 | m=$(echo $yl | cut -d\" -f4) |
Thomas Vachuska | 411de78 | 2017-07-18 14:22:38 -0700 | [diff] [blame] | 26 | m=${m/$BVER/$SVER} |
Thomas Vachuska | 692dcb0 | 2017-03-15 09:13:50 -0700 | [diff] [blame] | 27 | j=$(find $YANG_TOOLS_ROOT -name $n-$SVER.jar) |
| 28 | s=yang/$(basename $j) |
| 29 | cp $j $ONOS_ROOT/lib/$s |
| 30 | |
| 31 | # echo $n, $m, $j |
| 32 | |
| 33 | cat <<EOF >>$ONOS_ROOT/lib/BUCK |
| 34 | prebuilt_jar ( |
| 35 | name = '$n', |
| 36 | binary_jar = '$s', |
| 37 | maven_coords = '${m#mvn:*}', |
| 38 | visibility = [ 'PUBLIC' ], |
| 39 | ) |
| 40 | |
| 41 | EOF |
| 42 | done |
Thomas Vachuska | c32dfba | 2017-07-18 16:01:40 -0700 | [diff] [blame] | 43 | |
Yuta HIGUCHI | 9e11b09 | 2017-08-11 13:51:47 -0700 | [diff] [blame] | 44 | YANG_PLUGIN_SRC=$YANG_TOOLS_ROOT/compiler/plugin/buck/target/onos-yang-compiler-buck-plugin-$SVER.jar |
| 45 | if [ ! -f "$YANG_PLUGIN_SRC" ]; then |
| 46 | mvn -f $YANG_TOOLS_ROOT/pom.xml -am -pl :onos-yang-compiler-buck-plugin install -DskipTests -Dcheckstyle.skip |
| 47 | fi |
Yuta HIGUCHI | 28bcaf1 | 2018-02-13 12:12:16 -0800 | [diff] [blame^] | 48 | # populate buck plugin cache with SNAPSHOT version |
| 49 | ARTIFACT="org.onosproject:onos-yang-compiler-buck-plugin:$SVER" |
| 50 | mvn org.apache.maven.plugins:maven-dependency-plugin:3.0.2:copy \ |
| 51 | -Dartifact=$ARTIFACT \ |
| 52 | -Dtransitive=false -Dmdep.overWriteSnapshots=true \ |
| 53 | -DoutputDirectory=$ONOS_ROOT/bin/cache > /dev/null |
| 54 | |
| 55 | # Patch the YANG BUCK plugin version specified |
| 56 | sed -i.bak "s/YANG_VER=\"$BVER\"/YANG_VER=\"$SVER\"/" $ONOS_ROOT/tools/build/onos-buck |