Created
June 3, 2019 19:17
-
-
Save arichiardi/d7542941be959f06e2d420d3bc12a5b1 to your computer and use it in GitHub Desktop.
Convert the output of mvn dependency:list to leiningen deps
This file contains 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
#!/usr/bin/env bash | |
set -euo pipefail | |
# The following is the mvn dependency:list expected output | |
# | |
# [INFO] The following files have been resolved: | |
# [INFO] com.elasticpath.service.tenant:tenant-service-model:jar:1.0-SNAPSHOT:compile | |
# [INFO] com.elasticpath.service.tenant:tenant-service-dao:jar:1.0-SNAPSHOT:compile | |
# We need to get rid of some cruft first, like [INFO]. Note that we also need | |
# to start consuming line that have more than one whitespace after [INFO]. | |
# Handling both stdin and file with the while loop | |
# https://stackoverflow.com/questions/6980090/how-to-read-from-a-file-or-stdin-in-bash | |
while IFS= read -r line; do | |
printf '%s\n' "$line" | \ | |
sed -n -e 's/^\[.*\]\s\{2,\}\(.*\)/\1/p' | \ | |
awk -F: '{ print "["$1"/"$2 " \"" $4"\"]" }' | |
done < "${1:-/dev/stdin}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment