From: Carsten Lund Date: Mon, 6 Mar 2017 20:55:49 +0000 (+0000) Subject: [DCAE-1] Added script to update version in POM. X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F05%2F1705%2F1;p=dcae%2Fdemo.git [DCAE-1] Added script to update version in POM. Change-Id: I1f6f74602ed5720afd7291ae77236ab0532aa041 Signed-off-by: Carsten Lund --- 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 +