I’m sure this is not the first time I prepare a post like this, but I might have decided to last minute drop it: this time it’s not going to happen.
Sadly I have to use Windows at work and when I have some spare time I do contribute to Open Source Software and I have once again came face to face with the hell caused by trying to run a Maven Release Plugin on a Github hosted project. In this particular case it was a project I started myself called SmartUnit, but you can bet the same applies to any other Github hosted project using Maven and willing to perform releases on the Maven Central Repository.
Where do my problems start? Well, when I run the infamous
mvn release:prepare obviously.
First I started encountering failures with the missing commands:
gpg.exemust be installed and available on the PATH to be able to sign the packages for the Maven Central Repository
git.exemust be installed and available on the PATH to be able to commit the tag and updated pom to Github
Installing the above though does solve only a fraction of the problem as you need the corresponding keys:
- your GPG key should go into
%APPDATA%\gnupgand it’s easier if it is the first key in your GPG key store
- your SSH key should go into
%USERPROFILE%\.sshand, to avoid further complications, just name the file as
As if it wasn’t enough hassle, you have to manually start an SSH agent to provide the SSH key, so don’t forget to (commands should be already on the PATH at this stage):
- run the Git’s bash shell with
- run the SSH agent with
- add your SSH key with
ssh-add ~\.ssh\id_rsaand input the key passphrase
If your key wasn’t already listed among your Github SSH Keys, don’t forget to add it.
Now the Maven
release:prepare goal should complete successfully, but problems might arise during the release:prepare one as:
- the PGP key must be publicly verifiable, so it must be published like on http://pgp.mit.edu/ (you can use
gpg --armour --exportto obtain the key signature to submit)
- your Sonatype nexus credentials must be in your Maven
settings.xml, under a server directive using an id matching the distribution repository (it should be
sonatype-nexus-staging, but it might change over time)
Do you believe it’s all? Well, it’s not! Now you need to:
- log into your Sonatype Nexus account
- search your newly created Staging Repostory
- select the repository and close
- wait and refresh the view until it is reported as closed
- select the repository and release it!
Only at this point your artifacts will be available on the Maven Central Repository…
This is what I’ve twice learnt about the release process and what I hope I will be able to retrieve here the next time I’ll have to set this thing up again.
Might the force be with you!