Migration Guide¶
This guide helps you migrate to the Central Portal Publisher plugin from other publishing solutions or upgrade between plugin versions.
Migrating from OSSRH/Nexus Publishing¶
If you're currently using the traditional OSSRH (OSS Repository Hosting) with maven-publish and signing plugins:
Before (Traditional OSSRH)¶
plugins {
`maven-publish`
signing
}
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
pom {
name.set("My Library")
description.set("A useful library")
url.set("https://github.com/myorg/my-library")
licenses {
license {
name.set("Apache License 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("myid")
name.set("My Name")
email.set("me@example.com")
}
}
scm {
connection.set("scm:git:git://github.com/myorg/my-library.git")
developerConnection.set("scm:git:ssh://github.com/myorg/my-library.git")
url.set("https://github.com/myorg/my-library")
}
}
}
}
repositories {
maven {
name = "OSSRH"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = project.findProperty("ossrhUsername")?.toString()
password = project.findProperty("ossrhPassword")?.toString()
}
}
}
}
signing {
sign(publishing.publications["maven"])
}
After (Central Portal Publisher)¶
plugins {
id("com.tddworks.central-publisher") version "0.2.1-alpha"
}
centralPublisher {
credentials {
username = project.findProperty("SONATYPE_USERNAME")?.toString() ?: ""
password = project.findProperty("SONATYPE_PASSWORD")?.toString() ?: ""
}
projectInfo {
name = "My Library"
description = "A useful library"
url = "https://github.com/myorg/my-library"
license {
name = "Apache License 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
}
developer {
id = "myid"
name = "My Name"
email = "me@example.com"
}
scm {
url = "https://github.com/myorg/my-library"
connection = "scm:git:git://github.com/myorg/my-library.git"
developerConnection = "scm:git:ssh://github.com/myorg/my-library.git"
}
}
signing {
key = project.findProperty("SIGNING_KEY")?.toString() ?: ""
password = project.findProperty("SIGNING_PASSWORD")?.toString() ?: ""
}
}
Key Differences¶
- Simpler configuration - No need to manually configure
publishingandsigning - Auto-detection - Many fields can be auto-detected from git
- New credentials - Use Central Portal token instead of OSSRH password
- Single bundle - All artifacts uploaded in one deployment
- Manual approval - Review in Central Portal web interface before publishing
Migration Steps¶
- Get Central Portal account at central.sonatype.com
- Verify your namespace (same as your group ID)
- Generate user token for authentication
- Run setup wizard:
./gradlew setupPublishing --console=plain - Remove old configuration (publishing, signing blocks)
- Update CI/CD with new credentials and tasks
Migrating from Gradle Maven Publish Plugin¶
If you're using com.vanniktech.maven.publish:
Before¶
plugins {
id("com.vanniktech.maven.publish") version "0.25.3"
}
mavenPublishing {
coordinates("com.example", "my-library", "1.0.0")
pom {
name.set("My Library")
description.set("A useful library")
inceptionYear.set("2023")
url.set("https://github.com/myorg/my-library")
licenses {
license {
name.set("Apache License 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("myid")
name.set("My Name")
email.set("me@example.com")
}
}
scm {
url.set("https://github.com/myorg/my-library")
connection.set("scm:git:git://github.com/myorg/my-library.git")
developerConnection.set("scm:git:ssh://github.com/myorg/my-library.git")
}
}
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
}
After¶
plugins {
id("com.tddworks.central-publisher") version "0.2.1-alpha"
}
group = "com.example"
version = "1.0.0"
centralPublisher {
// Same configuration as shown above
}
Key Changes¶
- Replace
mavenPublishingwithcentralPublisher - Move
coordinates()to rootgroupandversion - Simpler signing configuration
- Interactive setup wizard available
Upgrading Plugin Versions¶
From 0.1.x to 0.2.x¶
Breaking Changes:
- DSL Name Change: ```kotlin // Old (deprecated) sonatypePortalPublisher { // config }
// New centralPublisher { // same config structure } ```
- Task Name Changes:
publishToSonatypePortal→publishToCentral-
bundleForSonatypePortal→bundleArtifacts -
Configuration Structure: Most configuration remains the same, but some field names changed: ```kotlin // Old sonatypePortalPublisher { username = "..." password = "..." }
// New
centralPublisher {
credentials {
username = "..."
password = "..."
}
}
```
Migration Steps:
-
Update plugin version:
kotlin plugins { id("com.tddworks.central-publisher") version "0.2.1-alpha" } -
Run migration wizard:
bash ./gradlew setupPublishing --console=plainThis will automatically migrate your old configuration. -
Update CI/CD scripts: ```yaml # Old
- run: ./gradlew publishToSonatypePortal
# New - run: ./gradlew publishToCentral ```
- Test the migration:
bash ./gradlew validatePublishing
From 0.2.x to 0.3.x (Future)¶
When available, upgrade steps will be documented here.
Migrating Multi-Module Projects¶
Before (Manual Configuration)¶
// Root build.gradle.kts
subprojects {
apply(plugin = "maven-publish")
apply(plugin = "signing")
publishing {
// Duplicate configuration in each module
}
signing {
// Duplicate signing configuration
}
}
After (Simplified)¶
// Root build.gradle.kts
plugins {
id("com.tddworks.central-publisher") version "0.2.1-alpha"
}
// Single configuration applies to all modules
centralPublisher {
// Configuration here
}
// Each module build.gradle.kts
plugins {
`maven-publish` // Still required
}
Environment Variable Migration¶
Old OSSRH Variables¶
# OSSRH (old)
export OSSRH_USERNAME=your-username
export OSSRH_PASSWORD=your-password
export SIGNING_KEY_ID=your-key-id
export SIGNING_PASSWORD=your-gpg-password
export SIGNING_SECRET_KEY_RING_FILE=/path/to/secring.gpg
New Central Portal Variables¶
# Central Portal (new)
export SONATYPE_USERNAME=your-username
export SONATYPE_PASSWORD=your-central-token
export SIGNING_KEY="-----BEGIN PGP PRIVATE KEY BLOCK-----..."
export SIGNING_PASSWORD=your-gpg-password
CI/CD Migration¶
GitHub Actions¶
Before (OSSRH):
- name: Publish to Maven Central
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
After (Central Portal):
- name: Publish to Maven Central
run: ./gradlew publishToCentral
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
Key Changes: - Simpler single-step publishing - No need for staging repository management - Updated secret names - Reduced complexity
Common Migration Issues¶
"Namespace not verified"¶
When migrating from OSSRH to Central Portal:
- Verify your namespace in Central Portal
- Same group ID should work if you had OSSRH access
- Complete verification process if needed
"Authentication failed"¶
- Use Central Portal token, not OSSRH password
- Generate token at central.sonatype.com
- Update CI/CD secrets with new credentials
"GPG key issues"¶
-
Export full armored key:
bash gpg --armor --export-secret-keys your-email@example.com -
Include complete headers/footers
- Test signing before migration:
bash echo "test" | gpg --armor --detach-sign --local-user your-email@example.com
"Publication not found"¶
Ensure you still have necessary plugins:
plugins {
`maven-publish` // Still required
// Remove `signing` plugin - handled by central-publisher
}
Rollback Strategy¶
If you need to rollback to your previous setup:
- Keep backup of your old build.gradle.kts
- Preserve old CI/CD scripts
- Keep old credentials as backup
- Test rollback in a separate branch first
Validation After Migration¶
After migration, validate everything works:
# 1. Validate configuration
./gradlew validatePublishing
# 2. Test bundle creation
./gradlew bundleArtifacts
# 3. Dry run publish
./gradlew publishToCentral -PdryRun=true
# 4. Full publish (when ready)
./gradlew publishToCentral
Getting Help¶
If you encounter issues during migration:
- Run the setup wizard:
./gradlew setupPublishing --console=plain - Check troubleshooting guide: troubleshooting.md
- Search existing issues: GitHub Issues
- Ask for help: Create a new issue with migration details
The setup wizard can automatically detect and migrate most configurations, making the migration process smoother.