Skip to content

Instantly share code, notes, and snippets.

@rishabh9
Created November 15, 2017 05:21
Show Gist options
  • Save rishabh9/183cc0c4c3ada4f8df94d65fcd73a502 to your computer and use it in GitHub Desktop.
Save rishabh9/183cc0c4c3ada4f8df94d65fcd73a502 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