summaryrefslogtreecommitdiffstats
path: root/jjb/include-update-pom-versions-not-parent.sh
blob: ace2350a2b19f15ed213431dfbf3a0c9a6bc6e73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/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
    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