Update versions for Kohn
[ccsdk/parent.git] / tools / mkbom.sh
1 #!/bin/bash
2
3 if [ $# -ne 3 ]
4 then
5   echo "Usage: $0 groupId artifactId version"
6   exit 1
7 fi
8
9 pomGroupId=$1
10 pomArtifactId=$2
11 pomVersion=$3
12
13 jarlist=/tmp/mkbom-jar-$$
14
15
16
17 # Make list of jars
18 for jar in $(find . -name '*.jar' -print | cut -d'/' -f2- | sort)
19 do
20     version=$(echo $jar | rev | cut -d'/' -f2 | rev)
21     artifactId=$(echo $jar | rev | cut -d'/' -f3 | rev)
22     groupId=$(echo $jar | rev | cut -d'/' -f4- | rev | tr '/' '.')
23     echo "$groupId|$artifactId|$version" >> $jarlist
24 done
25
26
27
28 cat <<END
29 <?xml version="1.0" encoding="UTF-8"?>
30 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
31     <modelVersion>4.0.0</modelVersion>
32
33     <groupId>$pomGroupId</groupId>
34     <artifactId>$pomArtifactId</artifactId>
35     <version>$pomVersion</version>
36     <packaging>pom</packaging>
37
38     <distributionManagement>
39         <repository>
40             <id>ecomp-releases</id>
41             <url>https://nexus.onap.org/content/repositories/releases</url>
42         </repository>
43         <snapshotRepository>
44             <id>ecomp-snapshots</id>
45             <url>https://nexus.onap.org/content/repositories/snapshots</url>
46         </snapshotRepository>
47     </distributionManagement>
48
49     <dependencyManagement>
50         <dependencies>
51 END
52
53 lastGroupId="UNSET"
54 lastArtifactId="UNSET"
55 lastVersion="UNSET"
56 for ln in $(cat $jarlist | sort -u)
57 do
58
59     groupId=$(echo $ln | cut -d'|' -f1)
60     artifactId=$(echo $ln | cut -d'|' -f2)
61     version=$(echo $ln | cut -d'|' -f3)
62
63     if [ "$lastGroupId" != "UNSET" ]
64     then
65         if [ "$lastGroupId" != "$groupId" -o "$lastArtifactId" != "$artifactId" ]
66         then
67             echo "            <dependency>"
68             echo "                <groupId>$lastGroupId</groupId>"
69             echo "                <artifactId>$lastArtifactId</artifactId>"
70             echo "                <version>$lastVersion</version>"
71             echo "            </dependency>"
72         fi
73     fi
74     lastGroupId=$groupId
75     lastArtifactId=$artifactId
76     lastVersion=$version
77 done
78
79 echo "            <dependency>"
80 echo "                <groupId>$lastGroupId</groupId>"
81 echo "                <artifactId>$lastArtifactId</artifactId>"
82 echo "                <version>$lastVersion</version>"
83 echo "            </dependency>"
84
85 cat  <<END
86         </dependencies>
87     </dependencyManagement>
88     
89     <build>
90         <plugins>
91             <plugin>
92                 <groupId>org.apache.maven.plugins</groupId>
93                 <artifactId>maven-deploy-plugin</artifactId>
94                 <!-- This version supports the "deployAtEnd" parameter -->
95                 <version>2.8</version>
96                 <configuration>
97                     <skip/>
98                     <deployAtEnd>true</deployAtEnd>
99                 </configuration>
100             </plugin>
101         </plugins>
102     </build>
103 </project>
104 END