Timoney, Dan (dt5972) | 0d2d736 | 2019-01-07 15:29:18 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | updatePom() { |
| 4 | cat $1 | xsltproc -o $1 /tmp/rebase-pom.xslt - |
| 5 | } |
| 6 | |
| 7 | export -f updatePom |
| 8 | |
| 9 | # Create XSLT script |
| 10 | newVersion=$2 |
| 11 | echo "newVersion is $newVersion" |
| 12 | cat <<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) | 96babb9 | 2020-03-06 16:40:25 -0500 | [diff] [blame] | 19 | <xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="no" cdata-section-elements="sdnc.keypass"/> |
Timoney, Dan (dt5972) | 0d2d736 | 2019-01-07 15:29:18 -0500 | [diff] [blame] | 20 | |
| 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Ürre | c6bdd9a | 2020-12-01 13:34:56 +0100 | [diff] [blame] | 30 | <version>$newVersion</version> |
Timoney, Dan (dt5972) | 0d2d736 | 2019-01-07 15:29:18 -0500 | [diff] [blame] | 31 | </xsl:template> |
| 32 | </xsl:stylesheet> |
| 33 | END |
| 34 | |
| 35 | if [ $# -ne 2 ] |
| 36 | then |
| 37 | echo "Usage: $0 <directory> <version>" |
| 38 | exit 1 |
| 39 | fi |
| 40 | |
| 41 | find $1 -name pom.xml -exec bash -c 'updatePom "$0" $1' '{}' \; |
Singal, Kapil (ks220y) | 96babb9 | 2020-03-06 16:40:25 -0500 | [diff] [blame] | 42 | |
| 43 | #Adding single empty line before project tag if there is a header available |
Dan Timoney | 8ca0f1f | 2020-04-09 14:46:31 -0400 | [diff] [blame] | 44 | find $1 -name pom.xml -exec sed -i '' '$!N;s@-->\n<project@-->\ |
| 45 | \ |
| 46 | <project@;P;D' {} \; |