summaryrefslogtreecommitdiffstats
path: root/tools/updParentVersion.sh
blob: 90f8d5c6aebf4c017ecf6667eab4ba9f020b2324 (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
39
40
41
42
43
44
45
46
#!/bin/bash

updatePom() {
cat $1 | xsltproc -o $1 /tmp/rebase-pom.xslt -
}

export -f updatePom

# Create XSLT script
newVersion=$2
echo "newVersion is $newVersion"
cat <<END > /tmp/rebase-pom.xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:pom="http://maven.apache.org/POM/4.0.0"
    xmlns="http://maven.apache.org/POM/4.0.0"
    exclude-result-prefixes="pom">
    <xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="no" cdata-section-elements="sdnc.keypass"/>

    <!-- Copy everything that does not match a rewrite rule -->
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()" />
        </xsl:copy>
    </xsl:template>

    <!-- Change ccsdk parent pom version -->
    <xsl:template match="//pom:parent[pom:groupId='org.onap.ccsdk.parent']/pom:version">
    <version>$newVersion</version>
    </xsl:template>
</xsl:stylesheet>
END

if [ $# -ne 2 ]
then
	echo "Usage: $0 <directory> <version>"
	exit 1
fi

find $1 -name pom.xml -exec bash -c 'updatePom "$0" $1' '{}' \;

#Adding single empty line before project tag if there is a header available
find $1 -name pom.xml -exec sed -i '' '$!N;s@-->\n<project@-->\
\
<project@;P;D' {} \;