Carsten Lund | 2d06a69 | 2017-02-23 18:23:07 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | ## Will update POM in workspace with release version |
| 4 | |
| 5 | if [ ! -e version.properties ]; then |
| 6 | echo "Missing version.properties" |
| 7 | exit 1 |
| 8 | fi |
| 9 | |
| 10 | ## will setup variable release_version |
| 11 | source ./version.properties |
| 12 | |
Carsten Lund | 64f2558 | 2017-03-04 14:23:29 +0000 | [diff] [blame] | 13 | RELEASE_VERSION=$release_version |
Carsten Lund | 2d06a69 | 2017-02-23 18:23:07 +0000 | [diff] [blame] | 14 | |
Carsten Lund | 64f2558 | 2017-03-04 14:23:29 +0000 | [diff] [blame] | 15 | echo Changing POM version to $RELEASE_VERSION |
Carsten Lund | c27b091 | 2017-02-24 00:10:24 +0000 | [diff] [blame] | 16 | |
Carsten Lund | 64f2558 | 2017-03-04 14:23:29 +0000 | [diff] [blame] | 17 | ## handle POM |
Carsten Lund | 2d06a69 | 2017-02-23 18:23:07 +0000 | [diff] [blame] | 18 | for file in $(find . -name pom.xml); do |
Carsten Lund | 64f2558 | 2017-03-04 14:23:29 +0000 | [diff] [blame] | 19 | VERSION=$(xpath -q -e '//project/version/text()' $file) |
| 20 | PVERSION=$(xpath -q -e '//project/parent/version/text()' $file) |
| 21 | echo before changes VERSION=$VERSION PVERSION=$PVERSION file=$file |
| 22 | if [ "$VERSION" != "" ]; then |
| 23 | awk -v v=$RELEASE_VERSION ' |
| 24 | /<version>/ { |
| 25 | if (! done) { |
| 26 | sub(/<version>.*</,"<version>" v "<",$0) |
| 27 | done = 1 |
| 28 | } |
| 29 | } |
| 30 | { print $0 } |
| 31 | ' $file > $file.tmp |
| 32 | mv $file.tmp $file |
Carsten Lund | 2d06a69 | 2017-02-23 18:23:07 +0000 | [diff] [blame] | 33 | fi |
Carsten Lund | 64f2558 | 2017-03-04 14:23:29 +0000 | [diff] [blame] | 34 | if [ "$PVERSION" != "" ]; then |
| 35 | awk -v v=$RELEASE_VERSION ' |
| 36 | /<version>/ { |
| 37 | if (parent && ! done) { |
| 38 | sub(/<version>.*</,"<version>" v "<",$0) |
| 39 | done = 1 |
| 40 | } |
| 41 | } |
| 42 | /<parent>/ { parent = 1 } |
| 43 | { print $0 } |
| 44 | ' $file > $file.tmp |
| 45 | mv $file.tmp $file |
| 46 | fi |
| 47 | VERSION=$(xpath -q -e '//project/version/text()' $file) |
| 48 | PVERSION=$(xpath -q -e '//project/parent/version/text()' $file) |
| 49 | echo after changes VERSION=$VERSION PVERSION=$PVERSION file=$file |
Carsten Lund | 2d06a69 | 2017-02-23 18:23:07 +0000 | [diff] [blame] | 50 | done |
| 51 | |