Skip to content

Commit 679a648

Browse files
committed
Fix maven central publishing
The `io.codearte.gradle.nexus:gradle-nexus-staging-plugin` was failing on the close and release step of sonatype publishing. This switches to using `io.github.gradle-nexus.publish-plugin` that handles this and the whole sonatype publishing more gracefully.
1 parent 9c042eb commit 679a648

File tree

3 files changed

+26
-34
lines changed

3 files changed

+26
-34
lines changed

.github/workflows/publish-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
env:
2525
GITHUB_SECRET_PASSPHRASE: ${{ secrets.SECRETS_TAR_PASSPHRASE }}
2626
- name: Publish to MavenCentral
27-
run: ./gradlew --info bundleReleaseAar publishReleasePublicationToSonatypeRepository closeAndReleaseRepository
27+
run: ./gradlew bundleReleaseAar publishToSonatype closeAndReleaseSonatypeStagingRepository

build.gradle

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2-
32
buildscript {
43
ext {
54
sdkCompileVersion = 28
@@ -74,16 +73,15 @@ buildscript {
7473
classpath 'com.android.tools.build:gradle:4.1.0'
7574
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
7675

77-
// Maven Central publishing
78-
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.13.0'
79-
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.4.10.2'
80-
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.22.0'
81-
8276
// NOTE: Do not place your application dependencies here; they belong
8377
// in the individual module build.gradle files
8478
}
8579
}
8680

81+
plugins {
82+
id("io.github.gradle-nexus.publish-plugin") version "1.0.0"
83+
}
84+
8785
allprojects {
8886
repositories {
8987
jcenter()
@@ -106,4 +104,23 @@ subprojects {
106104
tasks.withType(Javadoc).all { enabled = false }
107105
}
108106

109-
apply plugin: 'io.codearte.nexus-staging'
107+
File ossrhProp = project.rootProject.file('ossrh.properties')
108+
if (ossrhProp.exists()) {
109+
Properties p = new Properties()
110+
p.load(new FileInputStream(ossrhProp))
111+
p.each { name, value ->
112+
ext[name] = value
113+
}
114+
115+
group coreGroupId
116+
version coreVersion
117+
118+
nexusPublishing {
119+
repositories {
120+
sonatype {
121+
username = ossrhUsername
122+
password = ossrhPassword
123+
}
124+
}
125+
}
126+
}

ossrh.gradle

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,35 +72,10 @@ if (ossrhProp.exists()) {
7272
}
7373
}
7474
}
75-
repositories {
76-
// The repository to publish to, Sonatype/MavenCentral
77-
maven {
78-
// This is an arbitrary name, you may also use "mavencentral" or
79-
// any other name that's descriptive for you
80-
name = "sonatype"
81-
82-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
83-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
84-
// You only need this if you want to publish snapshots, otherwise just set the URL
85-
// to the release repo directly
86-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
87-
88-
// The username and password we've fetched earlier
89-
credentials {
90-
username ossrhUsername
91-
password ossrhPassword
92-
}
93-
}
94-
}
9575
}
9676
signing {
9777
sign publishing.publications
9878
}
9979

100-
nexusStaging {
101-
packageGroup publishGroupId
102-
stagingProfileId stagingProfileId
103-
username ossrhUsername
104-
password ossrhPassword
105-
}
80+
10681
}

0 commit comments

Comments
 (0)