blob: fcaed72c06ffb06fec6a179403e68f4f8beebf29 [file] [log] [blame]
Dan Timoney7f239072020-06-01 09:28:12 -04001#!/bin/bash
2
3if [ $# -ne 3 ]
4then
5 echo "Usage: $0 groupId artifactId version"
6 exit 1
7fi
8
9pomGroupId=$1
10pomArtifactId=$2
11pomVersion=$3
12
Dan Timoney06b50032021-06-07 13:55:46 -040013jarlist=/tmp/mkbom-jar-$$
14
15
16
17# Make list of jars
18for jar in $(find . -name '*.jar' -print | cut -d'/' -f2- | sort)
19do
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
24done
25
26
27
Dan Timoney7f239072020-06-01 09:28:12 -040028cat <<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>
51END
52
Dan Timoney06b50032021-06-07 13:55:46 -040053lastGroupId="UNSET"
54lastArtifactId="UNSET"
55lastVersion="UNSET"
56for ln in $(cat $jarlist | sort -u)
Dan Timoney7f239072020-06-01 09:28:12 -040057do
Dan Timoney7f239072020-06-01 09:28:12 -040058
Dan Timoney06b50032021-06-07 13:55:46 -040059 groupId=$(echo $ln | cut -d'|' -f1)
60 artifactId=$(echo $ln | cut -d'|' -f2)
61 version=$(echo $ln | cut -d'|' -f3)
Dan Timoney7f239072020-06-01 09:28:12 -040062
Dan Timoney06b50032021-06-07 13:55:46 -040063 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
Dan Timoney7f239072020-06-01 09:28:12 -040077done
78
Dan Timoney06b50032021-06-07 13:55:46 -040079echo " <dependency>"
80echo " <groupId>$lastGroupId</groupId>"
81echo " <artifactId>$lastArtifactId</artifactId>"
82echo " <version>$lastVersion</version>"
83echo " </dependency>"
84
Dan Timoney7f239072020-06-01 09:28:12 -040085cat <<END
86 </dependencies>
87 </dependencyManagement>
Dan Timoney06b50032021-06-07 13:55:46 -040088
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>
Dan Timoney7f239072020-06-01 09:28:12 -0400103</project>
104END