https://github.com/alipsa/nexus-release-plugin
Automates the release process to release to maven central
https://github.com/alipsa/nexus-release-plugin
Last synced: 3 months ago
JSON representation
Automates the release process to release to maven central
- Host: GitHub
- URL: https://github.com/alipsa/nexus-release-plugin
- Owner: Alipsa
- License: mit
- Created: 2023-11-12T12:04:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2026-03-18T21:36:59.000Z (3 months ago)
- Last Synced: 2026-03-19T07:51:30.944Z (3 months ago)
- Language: Groovy
- Homepage:
- Size: 218 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nexus-release-plugin
[](https://github.com/Alipsa/nexus-release-plugin/actions/workflows/ci.yml)
[](https://docs.oracle.com/en/java/javase/17/)
[](https://groovy-lang.org/)
[](https://javadoc.io/doc/se.alipsa.nexus-release-plugin/se.alipsa.nexus-release-plugin.gradle.plugin)
Automates the release process to Sonatype Central.
Assumptions are:
1. It assumes you use the maven publish plugin to define your artifacts
2. Any subproject (module) can use it in contrast to the nexus publish plugin which must be applied on the root project, allowing you to publish modules independently.
To use it you need to add your sonatype username token and password token to
~/.gradle/gradle.properties, e.g:
```properties
sonatypeUsername=myUserToken
sonatypePassword=myPassw0rdToken
```
Alternatively, you can set them as system properties or as environment variables.
Then you use the plugin in your build.gradle as follows:
```groovy
plugins {
// your other plugins...
id 'signing'
id 'maven-publish'
id 'se.alipsa.nexus-release-plugin' version '2.1.2'
}
publishing {
publications {
maven(MavenPublication) {
from components.java
artifact(javadocJar)
artifact(sourcesJar)
pom {
name = 'Your project name'
description = "${project.description}"
url = "https://github.com/yourGroup/yourProject"
licenses {
license {
name = 'MIT License'
url = 'https://raw.githubusercontent.com/yourGroup/yourProject/main/LICENSE'
}
}
developers {
developer {
id = 'nn'
name = 'Full Name'
}
}
scm {
url = 'https://github.com/yourGroup/yourProject/tree/main'
connection = 'scm:git:https://github.com/yourGroup/yourProject.git'
developerConnection = 'scm:git:https://github.com/yourGroup/yourProject.git'
}
}
}
}
}
nexusReleasePlugin {
userName = sonatypeUsername
password = sonatypePassword
mavenPublication = publishing.publications.maven
}
```
The plugin adds these tasks:
- `bundle`: creates the Maven Central bundle from the configured publication.
- `release`: validates and uploads the bundle to Central Portal.
- `latestMavenVersions`: lists the latest published version for the current project, and when run on the root project also for published subprojects that use this plugin.
If you want to publish to another url that behaves just like the Central Publishing API, you
can set the property `nexusUrl` in the nexusReleasePlugin e.g:
```groovy
nexusReleasePlugin {
nexusUrl = "https://central.sonatype.com/api/v1"
userName = sonatypeUsername
password = sonatypePassword
mavenPublication = publishing.publications.maven
}
```
If you need `latestMavenVersions` to query another Maven-compatible repository, set `metadataBaseUrl`:
```groovy
nexusReleasePlugin {
metadataBaseUrl = "https://repo1.maven.org/maven2"
mavenPublication = publishing.publications.maven
}
```
## Building the Plugin
```bash
./gradlew build # Build and test
./gradlew publishToMavenLocal # Publish to local Maven repo
```
## License
MIT License - see [LICENSE](LICENSE) for details.