From e4709a4207717ecd0de8f92082e6379ab1263ccf Mon Sep 17 00:00:00 2001 From: Carsten Lund Date: Mon, 6 Mar 2017 20:55:49 +0000 Subject: [DCAE-1] Added script to update version in POM. Change-Id: I1f6f74602ed5720afd7291ae77236ab0532aa041 Signed-off-by: Carsten Lund --- update-version.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 update-version.sh diff --git a/update-version.sh b/update-version.sh new file mode 100644 index 0000000..2d459d0 --- /dev/null +++ b/update-version.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +## Will update POM in workspace with release version + +if [ ! -e version.properties ]; then + echo "Missing version.properties" + exit 1 +fi + +## will setup variable release_version +source ./version.properties + +RELEASE_VERSION=$release_version + +echo Changing POM version to $RELEASE_VERSION + +## handle POM +for file in $(find . -name pom.xml); do + VERSION=$(xpath -q -e '//project/version/text()' $file) + PVERSION=$(xpath -q -e '//project/parent/version/text()' $file) + echo before changes VERSION=$VERSION PVERSION=$PVERSION file=$file + if [ "$VERSION" != "" ]; then + awk -v v=$RELEASE_VERSION ' + // { + if (! done) { + sub(/.*" v "<",$0) + done = 1 + } + } + { print $0 } + ' $file > $file.tmp + mv $file.tmp $file + fi + if [ "$PVERSION" != "" ]; then + awk -v v=$RELEASE_VERSION ' + // { + if (parent && ! done) { + sub(/.*" v "<",$0) + done = 1 + } + } + // { parent = 1 } + { print $0 } + ' $file > $file.tmp + mv $file.tmp $file + fi + VERSION=$(xpath -q -e '//project/version/text()' $file) + PVERSION=$(xpath -q -e '//project/parent/version/text()' $file) + echo after changes VERSION=$VERSION PVERSION=$PVERSION file=$file +done + -- cgit 1.2.3-korg