This guide is for library maintainers who need to publish new versions of Modo to Maven Central.
Create local.properties file in the project root (gitignored):
sonatypeUsername=your-central-portal-username
sonatypePassword=your-central-portal-password
signing.keyId=your-gpg-key-id
signing.password=your-gpg-key-password
signing.secretKeyRingFile=path/to/secring.gpgWhere to get credentials:
- Sonatype credentials: Register at Maven Central Portal and generate a user token
- GPG signing key: Generate using
gpg --gen-keyand export withgpg --export-secret-keys
Update the version in gradle/libs.versions.toml:
[versions]
modo = "x.y.z" # Update thisThis workflow publishes to a staging repository and validates artifacts, but requires manual approval before releasing to Maven Central.
./gradlew clean modo-compose:bundleReleaseAar publishAllPublicationsToSonatypeRepository closeSonatypeStagingRepositoryWhat happens:
- ✅ Artifacts are built (AAR, sources, javadoc)
- ✅ Artifacts are signed with GPG
- ✅ Uploaded to staging repository
- ✅ Repository is closed and validated
- ⏸️ Waits for manual approval
Next steps:
- Go to https://central.sonatype.com/publishing
- Find your deployment (should show as "VALIDATED")
- Review the artifacts
- Click "Publish" to release to Maven Central
- Or click "Drop" to discard if something is wrong
Why this is recommended:
- ✅ Review artifacts before public release
- ✅ Can drop/fix if errors are found
- ✅ Safer for production releases
⚠️ Remember: Once published, versions are immutable
This workflow automatically publishes to Maven Central after validation, with no manual review step.
./gradlew clean modo-compose:bundleReleaseAar \
publishAllPublicationsToSonatypeRepository \
closeAndReleaseSonatypeStagingRepositoryWhat happens:
- ✅ Artifacts are built, signed, and uploaded
- ✅ Repository is closed and validated
- ✅ Automatically released to Maven Central
- ⏳ Artifacts appear on Maven Central within 10-30 minutes
Use with caution:
⚠️ No manual review - artifacts become public immediately⚠️ Better for hotfixes or when you're very confident⚠️ Can't undo once released
# ❌ This will fail
./gradlew publishAllPublicationsToSonatypeRepository
./gradlew closeSonatypeStagingRepository # Error: No staging repository found
# ✅ This works
./gradlew publishAllPublicationsToSonatypeRepository closeSonatypeStagingRepositoryWhy? The staging repository ID is stored in Gradle's task state, which only exists during one session. See the note in the project explaining this behavior.
Once a version is published to Maven Central:
- ❌ Cannot be changed
- ❌ Cannot be deleted
- ❌ Cannot be republished
If you publish a broken version, you must release a new version with a fix.
- Validation: Immediate (during close task)
- Publication to Maven Central: 10-30 minutes after release
- Maven Central search: May take up to 2 hours to index
You're trying to republish an existing version. Solution:
- Bump the version in
gradle/libs.versions.toml - Or drop the deployment from https://central.sonatype.com/publishing (if not yet published)
Your credentials are invalid or from the old OSSRH system. Solution:
- Verify you're using credentials from https://central.sonatype.com (not oss.sonatype.org)
- Regenerate user token if needed
- Check
local.propertieshas correctsonatypeUsernameandsonatypePassword
You ran tasks in separate Gradle invocations. Solution:
- Run all tasks in a single command (see "Gradle Session State" above)
This project uses:
maven-publishplugin: Creates and signs artifacts (configured inPublishingPlugin.kt)gradle-nexus/publish-plugin: Manages Nexus staging workflow (configured in rootbuild.gradle.kts)- OSSRH Staging API compatibility endpoint: Bridges old Gradle plugins with new Central Portal
The migration from OSSRH to Central Portal is complete, using the compatibility endpoint to maintain existing workflow.