Skip to content

Instantly share code, notes, and snippets.

@on195594
Forked from rishabh9/upload.sh
Created September 24, 2021 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save on195594/6a5c0ba20fbb3ddc17b82df7d7c268b4 to your computer and use it in GitHub Desktop.
Save on195594/6a5c0ba20fbb3ddc17b82df7d7c268b4 to your computer and use it in GitHub Desktop.
Bulk upload your local maven repository to your private Nexus repository
#!/bin/sh
# Reference: http://roboojack.blogspot.in/2014/12/bulk-upload-your-local-maven-artifacts.html
if [ "$#" -ne 3 ] || ! [ -d "$1" ]; then
echo "Usage:"
echo " bash run.sh <repoRootFolder> <repositoryId> <repositoryUrl>"
echo ""
echo ""
echo " Where..."
echo " repoRootFolder: The folder containing the repository tree."
echo " Ensure you move the repository outside of ~/.m2 folder"
echo " or whatever is configured in settings.xml"
echo " repositoryId: The repositoryId from the <server> configured for the repositoryUrl in settings.xml."
echo " Ensure that you have configured username and password in settings.xml."
echo " repositoryUrl: The URL of the repository where you want to upload the files."
exit 1
fi
while read -r line ; do
echo "Processing file $line"
pomLocation=${line/./}
pomLocation=$PWD${pomLocation/jar/pom}
jarLocation=${line/./}
jarLocation=$PWD${jarLocation/pom/jar}
#echo $pomLocation
#echo $jarLocation
mvn deploy:deploy-file -DpomFile=$pomLocation -Dfile=$jarLocation -DrepositoryId=$2 -Durl=$3
done < <(find $1 -name "*.jar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment