Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.