publish-plugin
publish-plugin copied to clipboard
No staging repository with name sonatype created
I've been following a guide I found here on how to use this plugin (have tried 1.0.0 and 1.1.0) and can upload to staging successfully to mavenCentral however closeAndReleaseSonatypeStagingRepository
never resolves. Changing the name of the repository from sonatype to anything else seems to resolve in the same error with that name.
See gradle file for the project below.
apply plugin: "java-library"
apply plugin: "com.google.protobuf"
apply plugin: "maven-publish"
apply plugin: "signing"
apply plugin: "io.github.gradle-nexus.publish-plugin"
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
google()
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.14'
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
}
}
version = '0.25.0'
group = 'org.kin.agora.gen'
// Create variables with empty default values
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.secretKeyRingFile"] = ''
File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
Properties p = new Properties()
new FileInputStream(secretPropsFile).withCloseable { is ->
p.load(is)
}
p.each { name, value ->
ext[name] = value
}
} else {
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
}
// Set up Sonatype repository
nexusPublishing {
repositories {
sonatype {
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
repositories {
google()
mavenCentral()
maven {
url 'https://jitpack.io'
}
}
// We want to strip proto validation because it doesn't support protobuf-lite atm
// which we want for mobile usage to reduce dependencies and size
task removeProtoValidation(type: Exec) {
workingDir "${projectDir}"
commandLine './remove_proto_validation.sh'
}
tasks.whenTaskAdded { task ->
if (task.name == 'extractIncludeProto') {
task.dependsOn removeProtoValidation
}
}
def grpcVersion = "1.33.1"
def protocVersion = "3.12.0"
dependencies {
implementation "io.grpc:grpc-protobuf-lite:${grpcVersion}"
implementation "io.grpc:grpc-stub:${grpcVersion}"
}
def generatedSrcRoot = file("${buildDir}/generated/source/proto/main/java/")
sourceSets.main {
proto {
srcDir "${rootDir}/../../proto"
}
java {
srcDirs = ["${generatedSrcRoot}"]
}
}
compileJava {
options.annotationProcessorGeneratedSourcesDirectory generatedSrcRoot
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:${protocVersion}"
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option "lite"
}
}
}
all()*.plugins {
grpc {
option 'lite'
}
}
}
}
jar {
manifest {
attributes('agora-api': project.name,
'Version': project.version)
}
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives sourcesJar
}
publishing {
publications {
release(MavenPublication) {
from project.components.java
artifact sourcesJar
pom {
name = 'agora-api'
description = ''
url = 'https://github.com/kinecosystem/agora-api'
licenses {
license {
name = 'MIT License'
url = 'https://github.com/kinecosystem/agora-api/blob/master/LICENSE.md'
}
}
// Version control info - if you're using GitHub, follow the format as seen here
scm {
connection = 'scm:git:github.com/kinecosystem/agora-api.git'
developerConnection = 'scm:git:ssh://github.com/kinecosystem/agora-api.git'
url = 'https://github.com/kinecosystem/agora-api/tree/main'
}
withXml {
def depNode
def depNodes = asNode().get('dependencies')
if (depNodes.size() == 0) {
depNode = asNode().appendNode('dependencies')
} else {
depNode = depNodes.get(0)
}
// Iterate over the implementation dependencies (we don't want the test ones), adding a <dependency> node for each
configurations.implementation.allDependencies.each {
// Ensure dependencies such as fileTree are not included in the pom.
if (it.name != 'unspecified') {
def dependencyNode = depNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}
}
signing {
sign publishing.publications
}
We do not support Android projects (and monorepos). Probably you use a standard layout for Android projects and have a subproject with code. Your problem seems to be similar to https://github.com/gradle-nexus/publish-plugin/issues/74#issuecomment-789370339. If yes, you could subscribe to https://github.com/gradle-nexus/publish-plugin/issues/75 to get notified when it is implemented.
Anyway, the guide you mentioned seems to use our plugin. Do you know what differs your project and that in the article (where it seems to work fine)?
It's not an android project though, just a plain java library; or do you mean any monorepo project? The only difference seems to be that there isn't a base project, but I don't see why that would be a problem. Looking at this plugin's source it seems to maintain a lookup for repositories, and it fails to resolve it. Perhaps it's trying to resolve it on the root which it thinks doesn't exist but is actually also itself?
It's not an android project though, just a plain java library
Right, I was confused by the article you linked. You build.gradle
looks very generic :-)
The only difference seems to be that there isn't a base project
What do you mean? The configuration you pasted is from a subproject?
Do you have any staging repository related tasks when executed ./gradlew tasks --group publishing
?
I had the same problem. I solved it by executing both tasks in the same Gradle call:
./gradlew publishAllPublicationsToSonatypeRepository closeAndReleaseSonatypeStagingRepository
If I execute the tasks in two separate Gradle calls, the second task fails with No staging repository with name sonatype created
. I think this is a problem that needs to be fixed in the publish plugin.
@pemistahl Yes, you are right, they have to be called in the same Gradle call (until #19 is implemented) as publish*
triggers staging repository creation. Maybe we could improve the error message, but in the meantime, @pemistahl maybe you would like to provide a PR with README enhancement to emphasis that both commands have to be used in the same Gradle call?
@pemistahl Yes, you are right, they have to be called in the same Gradle call (until #19 is implemented) as
publish*
triggers staging repository creation. Maybe we could improve the error message, but in the meantime, @pemistahl maybe you would like to provide a PR with README enhancement to emphasis that both commands have to be used in the same Gradle call?
Has this changed recently ? This used to work, I had this configured in my CI script and did multiple releases in that way around July 2020.
Today I had to fix something in that project I hadn't touched for a long time, and the CI broke with the exact same issue as the OP.