I've used the nexus-workflow gradle plugin to automate the releasing of repositories.
I put this at the top of the build.gradle
of my project I want to release:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.adaptc.gradle:nexus-workflow:0.6'
}
}
apply plugin: 'nexus-workflow'
Additionally I put these three properties in ~/.gradle/gradle.properties
oss-releases.username=mySonatypeUsername
oss-releases.password=mySonatypePassword
oss-releases.url=https://oss.sonatype.org/index.html#stagingRepositories
When I want to push a release to Maven Central, I first upload the jars to Nexus using gradle uploadArchives
and then I do gradle nexusStagingRelease
. This closes and releases all my open repos on Nexus.
Edit: I also found this plugin by Benjamin Muschko which seems to be an alternative to the plugin described above. I didn't try it yet, though.