summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Lund <lund@research.att.com>2017-03-06 20:55:49 +0000
committerCarsten Lund <lund@research.att.com>2017-03-06 20:55:49 +0000
commite4709a4207717ecd0de8f92082e6379ab1263ccf (patch)
treea46bbbfeac48e65c5952534705a6722ba8f52e51
parent3ffc2b325ee3a1112afaa86d529ad6f439b4cde7 (diff)
[DCAE-1] Added script to update version in POM.
Change-Id: I1f6f74602ed5720afd7291ae77236ab0532aa041 Signed-off-by: Carsten Lund <lund@research.att.com>
-rw-r--r--update-version.sh51
1 files changed, 51 insertions, 0 deletions
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 '
+ /<version>/ {
+ if (! done) {
+ sub(/<version>.*</,"<version>" v "<",$0)
+ done = 1
+ }
+ }
+ { print $0 }
+ ' $file > $file.tmp
+ mv $file.tmp $file
+ fi
+ if [ "$PVERSION" != "" ]; then
+ awk -v v=$RELEASE_VERSION '
+ /<version>/ {
+ if (parent && ! done) {
+ sub(/<version>.*</,"<version>" v "<",$0)
+ done = 1
+ }
+ }
+ /<parent>/ { 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
+