Last active
July 31, 2019 23:19
-
-
Save guilhermetp/da156dccd412200aa3f4ac0c568f0b09 to your computer and use it in GitHub Desktop.
Bash file to import m2 dependencies to nexus
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 | |
BASEDIR=$(dirname "$0") | |
echo "$BASEDIR" | |
if [[ $# -eq 0 ]] ; then | |
echo 'How to \n\n\n import_nexus_dep.sh http://<YOURREPO> <USER> <PASS> <M2_PATHh> <FILTER(optional)>' | |
exit 0 | |
fi | |
server=$1 | |
user=$2 | |
pass=$3 | |
path=$4 | |
filter=$5 | |
cd $path repository | |
case "$#" in | |
4) find ./ \( -name '*.pom' -o -name '*.jar' \) -type f -print > $BASEDIR/dependencies.mig ;; | |
5) find ./ \( -name '*.pom' -o -name '*.jar' \) -type f -print | grep $5 > $BASEDIR/dependencies.mig ;; | |
esac | |
while read relative_path; do | |
echo $relative_path | |
# remove the dot to create the correct path | |
filename="${relative_path:17}" | |
echo "curl -v -u $user:$pass --upload-file $relative_path $server/$filename" | |
curl -v -u $user:$pass --upload-file $relative_path $server/$filename -o $BASEDIR/dependencies.out | |
done < $BASEDIR/dependencies.mig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment