blob: 90f8d5c6aebf4c017ecf6667eab4ba9f020b2324 [file] [log] [blame]
Timoney, Dan (dt5972)0d2d7362019-01-07 15:29:18 -05001#!/bin/bash
2
3updatePom() {
4cat $1 | xsltproc -o $1 /tmp/rebase-pom.xslt -
5}
6
7export -f updatePom
8
9# Create XSLT script
10newVersion=$2
11echo "newVersion is $newVersion"
12cat <<END > /tmp/rebase-pom.xslt
13<?xml version="1.0" encoding="utf-8"?>
14<xsl:stylesheet version="1.0"
15 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
16 xmlns:pom="http://maven.apache.org/POM/4.0.0"
17 xmlns="http://maven.apache.org/POM/4.0.0"
18 exclude-result-prefixes="pom">
Singal, Kapil (ks220y)96babb92020-03-06 16:40:25 -050019 <xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="no" cdata-section-elements="sdnc.keypass"/>
Timoney, Dan (dt5972)0d2d7362019-01-07 15:29:18 -050020
21 <!-- Copy everything that does not match a rewrite rule -->
22 <xsl:template match="@*|node()">
23 <xsl:copy>
24 <xsl:apply-templates select="@*|node()" />
25 </xsl:copy>
26 </xsl:template>
27
28 <!-- Change ccsdk parent pom version -->
29 <xsl:template match="//pom:parent[pom:groupId='org.onap.ccsdk.parent']/pom:version">
Michael DÜrrec6bdd9a2020-12-01 13:34:56 +010030 <version>$newVersion</version>
Timoney, Dan (dt5972)0d2d7362019-01-07 15:29:18 -050031 </xsl:template>
32</xsl:stylesheet>
33END
34
35if [ $# -ne 2 ]
36then
37 echo "Usage: $0 <directory> <version>"
38 exit 1
39fi
40
41find $1 -name pom.xml -exec bash -c 'updatePom "$0" $1' '{}' \;
Singal, Kapil (ks220y)96babb92020-03-06 16:40:25 -050042
43#Adding single empty line before project tag if there is a header available
Dan Timoney8ca0f1f2020-04-09 14:46:31 -040044find $1 -name pom.xml -exec sed -i '' '$!N;s@-->\n<project@-->\
45\
46<project@;P;D' {} \;