Skip to content

Instantly share code, notes, and snippets.

@ntung
Forked from Ladicek/maven-deploy-sources.sh
Created April 9, 2018 13:37
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 ntung/67ce404b98f990badba506cfdca4796e to your computer and use it in GitHub Desktop.
Save ntung/67ce404b98f990badba506cfdca4796e to your computer and use it in GitHub Desktop.
deploy *-sources.jar to internal Maven repository
#!/bin/bash
# successful "mvn clean install" or a variant thereof (e.g. -DskipTests)
# is typically required before running this script
REPOSITORY_ID=...
REPOSITORY_URL=...
mvn clean source:jar
for JAR in $(find . -name "*-sources.jar") ; do
echo $JAR
ABSOLUTE_PATH=$(readlink -f $JAR)
pushd $(dirname $JAR)/../ > /dev/null
GROUP_ID=$(mvn -o help:evaluate -Dexpression=project.groupId | grep -v -E '^\[|Downloading')
ARTIFACT_ID=$(mvn -o help:evaluate -Dexpression=project.artifactId | grep -v -E '^\[|Downloading')
VERSION=$(mvn -o help:evaluate -Dexpression=project.version | grep -v -E '^\[|Downloading')
echo $GROUP_ID:$ARTIFACT_ID:$VERSION
mvn deploy:deploy-file \
-Dfile=$ABSOLUTE_PATH \
-DrepositoryId=$REPOSITORY_ID \
-Durl=$REPOSITORY_URL \
-DgroupId=$GROUP_ID \
-DartifactId=$ARTIFACT_ID \
-Dversion=$VERSION \
-Dclassifier=sources \
-Dpackaging=jar \
-DgeneratePom=false
popd > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment