blob: 2d459d03ba8a8a4308dca2c0b9755a27bb5bd0fe [file] [log] [blame]
Carsten Lund2d06a692017-02-23 18:23:07 +00001#!/bin/bash
2
3## Will update POM in workspace with release version
4
5if [ ! -e version.properties ]; then
6 echo "Missing version.properties"
7 exit 1
8fi
9
10## will setup variable release_version
11source ./version.properties
12
Carsten Lund64f25582017-03-04 14:23:29 +000013RELEASE_VERSION=$release_version
Carsten Lund2d06a692017-02-23 18:23:07 +000014
Carsten Lund64f25582017-03-04 14:23:29 +000015echo Changing POM version to $RELEASE_VERSION
Carsten Lundc27b0912017-02-24 00:10:24 +000016
Carsten Lund64f25582017-03-04 14:23:29 +000017## handle POM
Carsten Lund2d06a692017-02-23 18:23:07 +000018for file in $(find . -name pom.xml); do
Carsten Lund64f25582017-03-04 14:23:29 +000019 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 Lund2d06a692017-02-23 18:23:07 +000033 fi
Carsten Lund64f25582017-03-04 14:23:29 +000034 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 Lund2d06a692017-02-23 18:23:07 +000050done
51