javagradledeploymentsonatype

How to deploy to ossrh-staging-api.central.sonatype.com with Gradle?


I want to deploy to the new staging repository from Sonatype with Gradle. Then I want release manually to the final maven repository. The Gradle script run without error but in the UI at https://central.sonatype.com/publishing/deployments there is nothing what I can release.

My shorted script look like:

buildscript {
    repositories {
        gradlePluginPortal()
    }
    dependencies {
        classpath 'io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin:+'
    }
}
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'io.github.gradle-nexus.publish-plugin'

nexusPublishing {
    repositories {
        sonatype {
            nexusUrl = uri('https://ossrh-staging-api.central.sonatype.com/service/local/')
            snapshotRepositoryUrl = uri('https://central.sonatype.com/repository/maven-snapshots/')
            username = project.findProperty('ossrhUsername')
            password = project.findProperty('ossrhPassword')
        }
    }
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java

            pom {
                ....
            }
        }
    }
}


signing {
    if (project.hasProperty("signing.keyId") ){
        sign publishing.publications.mavenJava
    }
}

closeStagingRepositories.dependsOn 'publishToSonatype'
publish.dependsOn 'closeStagingRepositories'

The I call the task publish. What I do wrong?


Solution

  • You must use the same account to access the user interface as the account you used to create the access token.