Created
October 25, 2021 13:29
-
-
Save vkasala/01829324f9df12d27a09db0cad14ba65 to your computer and use it in GitHub Desktop.
Generate effective tree for a parametrized pom, parse the eff tree's dependencyManagement section and output it as GAV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Download pom.xml with one bom | |
echo "Downloading pom.xml with ONE bom" | |
curl https://gitlab.cee.redhat.com/-/snippets/4370/raw/master/one-bom-generator.xml --output one-bom-generator.xml | |
BOM1_VERSION=2.2.0.fuse-800019-redhat-00001 | |
BOM1_GROUP_ID=org.apache.camel.quarkus | |
BOM1_ARTIFACT_ID=camel-quarkus-bom | |
EFF_POM_OUTPUT_FILE_NAME=${BOM1_GROUP_ID}-${BOM1_ARTIFACT_ID}-${BOM1_VERSION}-eff-pom.xml | |
OUTPUT_FILE_NAME=${BOM1_GROUP_ID}-${BOM1_ARTIFACT_ID}-${BOM1_VERSION}-list.txt | |
echo "Generating the effective pom" | |
mvn -ntp help:effective-pom -f one-bom-generator.xml -Doutput=${EFF_POM_OUTPUT_FILE_NAME} -Dbom1.version=${BOM1_VERSION} -Dbom1.group-id=${BOM1_GROUP_ID} -Dbom1.artifact-id=${BOM1_ARTIFACT_ID} | |
cat ${EFF_POM_OUTPUT_FILE_NAME} | \ | |
# Remove whitespaces | |
tr -d ' ' | \ | |
# Extract only section between <dependencyManagement>...</dependencyManagement> | |
sed -n '/^<dependencyManagement>$/,/^\s*<\/dependencyManagement>$/p' | \ | |
sed -n '/^<dependency>$/,/^\s*<\/dependency>$/p' | \ | |
sed '/<exclusions>/,/<\/exclusions>/d' | \ | |
sed 's/<groupId>//g' | \ | |
sed 's/<artifactId>//g' | \ | |
sed 's/<version>//g' | \ | |
sed 's/<\/version>//g' | \ | |
sed 's/<\/artifactId>/:/g' | \ | |
sed 's/<\/groupId>/:/g' | \ | |
sed 's/<\/dependency>//g' | \ | |
tr -d "\n" | \ | |
sed "s/<dependency>/\n/g" | tee ${OUTPUT_FILE_NAME} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment