Skip to content

Instantly share code, notes, and snippets.

@wvengen
Last active August 29, 2015 14:18
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 wvengen/29ed24da2f30f379e10b to your computer and use it in GitHub Desktop.
Save wvengen/29ed24da2f30f379e10b to your computer and use it in GitHub Desktop.
Create artifact bundle for Maven Central upload
#!/bin/sh
#
# I found the instructions for setting up Maven Central upload in pom.xml too involved.
# This does the job as well, though it requires manually uploading it in Maven Central's
# web interface as an artifact bundle.
#
# Usage:
# 1. Make sure your project is ready and the release version checked out
# 2. Change GPGKEY to point to your key in this script
# 3. Run this script in the directory containing pom.xml
# 4. upload target/bundle-x.y.z.zip to Maven Central as artifact bundle
#
# This might the invocation when pom.xml would be fully configured:
# mvn source:jar javadoc:jar package gpg:sign repository:bundle-create -Dgpg.keyname=me@example.com
#
GPGKEY=123456
NAME=`xpath -q -e '/project/name' pom.xml | sed 's/<[^>]*>//g'`
LAST=`xpath -q -e '/project/version' pom.xml | sed 's/<[^>]*>//g'`
rm -f target/$NAME-$LAST-* target/$NAME-$LAST.*
mvn source:jar javadoc:jar package
cp pom.xml target/$NAME-$LAST.pom
for i in target/$NAME-$LAST-* target/$NAME-$LAST.*; do
gpg -u $GPGKEY -b -a $i
done
cd target && zip bundle-$LAST.zip $NAME-$LAST-* $NAME-$LAST.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment