-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathlpkg2bom
executable file
·60 lines (45 loc) · 1.95 KB
/
lpkg2bom
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
install_jar() {
local ARTIFACT_ID=$(unzip -c $1 META-INF/MANIFEST.MF | sed -n "/Bundle-SymbolicName/,/^[^ ]/p" | sed '$d' | sed "1s/Bundle-SymbolicName://" | tr -d '[:space:]')
local VERSION=$(unzip -c $1 META-INF/MANIFEST.MF | grep -F Bundle-Version | sed 's/[\r\n]//g' | cut -d':' -f 2 | sed 's/ //g')
echo ' <dependency>
<groupId>'${GROUP_ID}'</groupId>
<artifactId>'${ARTIFACT_ID}'</artifactId>
<version>'${VERSION}'</version>
</dependency>' >> "${POM_FILE}"
if [ "" != "${GROUP_ID}" ]; then
mvn install:install-file -Dpackaging=jar -Dfile=$1 -DgroupId=${GROUP_ID} -DartifactId=${ARTIFACT_ID} -Dversion=${VERSION}
fi
}
install_lpkg() {
mkdir -p temp
unzip -uqq "${LPKG}" -d temp
local POM_ARTIFACT_ID=$(echo "${LPKG}" | tr '[:upper:]' '[:lower:]' | tr ' ' '.')
local POM_ARTIFACT_VERSION=$(grep '^version=' temp/liferay-marketplace.properties | cut -d'=' -f 2)
POM_FILE="${PWD}/${POM_ARTIFACT_ID}.pom"
echo '<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">
<modelVersion>4.0.0</modelVersion>
<groupId>'${GROUP_ID}'</groupId>
<artifactId>'${POM_ARTIFACT_ID}'.bom</artifactId>
<version>'${POM_ARTIFACT_VERSION}'</version>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>' > "${POM_FILE}"
for jar in temp/*.jar; do
install_jar "$jar"
done
echo ' </dependencies>
</dependencyManagement>
</project>' >> "${POM_FILE}"
rm -rf temp
if [ "" != "${GROUP_ID}" ]; then
mvn install:install-file -Dpackaging=pom -Dfile="${POM_FILE}" -DgroupId=${GROUP_ID} -DartifactId=${POM_ARTIFACT_ID}.bom -Dversion=${POM_ARTIFACT_VERSION}
fi
}
GROUP_ID=$1
LPKG=$2
if [ ! -f "${LPKG}" ]; then
echo 'Usage: lpkg2bom <GROUP_ID> <PATH_TO_LPKG>'
exit 1
fi
install_lpkg