Skip to content

Instantly share code, notes, and snippets.

@admanzoni
Created July 19, 2023 11:30
Show Gist options
  • Save admanzoni/8ef4e6eb115d6793ca64d524de803bb5 to your computer and use it in GitHub Desktop.
Save admanzoni/8ef4e6eb115d6793ca64d524de803bb5 to your computer and use it in GitHub Desktop.
Upload local jar to remote artifactory
#!/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
find $1 -type d -exec find {} -type f -name "*.pom" \; | while read -r line ; do
echo "Processing file $line"
#if [[ ${line} != *"SNAPSHOT"* ]];then
pomLocation=${line}
jarLocation=${line}
jarLocation=${jarLocation/pom/jar}
sourcesLocation=${line}
sourcesLocation=${sourcesLocation/.pom/-sources.jar}
javadocLocation=${line}
javadocLocation=${javadocLocation/.pom/-javadoc.jar}
mavenCmd="mvn deploy:deploy-file -DpomFile=${pomLocation}"
if [ -e "$jarLocation" ]; then
mavenCmd="${mavenCmd} -Dfile=${jarLocation}"
else
mavenCmd="${mavenCmd} -Dfile=${pomLocation}"
fi
if [ -e "$sourcesLocation" ]; then
mavenCmd="${mavenCmd} -Dsources=${sourcesLocation}"
fi
if [ -e "$javadocLocation" ]; then
mavenCmd="${mavenCmd} -Djavadoc=${javadocLocation}"
fi
echo $mavenCmd
#mvn deploy:deploy-file -DpomFile=$pomLocation -Dfile=$jarLocation -DrepositoryId=$2 -Durl=$3
#fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment