Skip to content

Commit f0287a4

Browse files
authored
Migrate publishing from OSSRH to Central (#385)
Use the OSSRH Staging API as a bridge for the new API until Sonatype provides a proper Gradle plugin
1 parent 6902e10 commit f0287a4

File tree

7 files changed

+39
-22
lines changed

7 files changed

+39
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ See also the [full License text](LICENSE).
315315
[junit5gh]: https://github.com/junit-team/junit5
316316
[junit5ug]: https://junit.org/junit5/docs/current/user-guide
317317
[circleci]: https://circleci.com/gh/mannodermaus/android-junit5
318-
[sonatyperepo]: https://oss.sonatype.org/content/repositories/snapshots
318+
[sonatyperepo]: https://central.sonatype.com/repository/maven-snapshots
319319
[sampletests]: instrumentation/sample
320320
[wiki-home]: https://github.com/mannodermaus/android-junit5/wiki
321321
[wiki-dsl]: https://github.com/mannodermaus/android-junit5/wiki/Configuration

README.md.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ See also the [full License text](LICENSE).
310310
[junit5gh]: https://github.com/junit-team/junit5
311311
[junit5ug]: https://junit.org/junit5/docs/current/user-guide
312312
[circleci]: https://circleci.com/gh/mannodermaus/android-junit5
313-
[sonatyperepo]: https://oss.sonatype.org/content/repositories/snapshots
313+
[sonatyperepo]: https://central.sonatype.com/repository/maven-snapshots
314314
[sampletests]: instrumentation/sample
315315
[wiki-home]: https://github.com/mannodermaus/android-junit5/wiki
316316
[wiki-dsl]: https://github.com/mannodermaus/android-junit5/wiki/Configuration

build-logic/src/main/kotlin/Deployment.kt

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ private fun Project.configureRootDeployment(deployConfig: Deployed, credentials:
150150
group = deployConfig.groupId
151151
version = deployConfig.currentVersion
152152

153-
nexusPublishing(
154-
packageGroup = deployConfig.groupId,
155-
stagingProfileId = credentials.sonatypeStagingProfileId,
156-
sonatypeUsername = credentials.ossrhUsername,
157-
sonatypePassword = credentials.ossrhPassword
153+
centralPublishing(
154+
packageGroup = deployConfig.groupId,
155+
stagingProfileId = credentials.sonatypeStagingProfileId,
156+
username = credentials.centralUsername,
157+
password = credentials.centralPassword
158158
)
159159
}
160160

@@ -348,11 +348,11 @@ private fun Project.signing(action: SigningExtension.() -> Unit) {
348348

349349
// Nexus Staging & Publishing Plugins facade
350350

351-
private fun Project.nexusPublishing(
352-
packageGroup: String,
353-
stagingProfileId: String?,
354-
sonatypeUsername: String?,
355-
sonatypePassword: String?
351+
private fun Project.centralPublishing(
352+
packageGroup: String,
353+
stagingProfileId: String?,
354+
username: String?,
355+
password: String?
356356
) {
357357
extensions.getByName("nexusPublishing").withGroovyBuilder {
358358
setProperty("packageGroup", packageGroup)
@@ -368,11 +368,19 @@ private fun Project.nexusPublishing(
368368

369369
cls.getDeclaredMethod("setUsername", Any::class.java)
370370
.also { it.isAccessible = true }
371-
.invoke(delegate, sonatypeUsername)
371+
.invoke(delegate, username)
372372

373373
cls.getDeclaredMethod("setPassword", Any::class.java)
374374
.also { it.isAccessible = true }
375-
.invoke(delegate, sonatypePassword)
375+
.invoke(delegate, password)
376+
377+
cls.getDeclaredMethod("setNexusUrl", Any::class.java)
378+
.also { it.isAccessible = true }
379+
.invoke(delegate, uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
380+
381+
cls.getDeclaredMethod("setSnapshotRepositoryUrl", Any::class.java)
382+
.also { it.isAccessible = true }
383+
.invoke(delegate, uri("https://central.sonatype.com/repository/maven-snapshots/"))
376384
}
377385
}
378386
}

build-logic/src/main/kotlin/Environment.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ class DeployedCredentials(private val project: Project) {
149149
var signingKeyId: String?
150150
var signingPassword: String?
151151
var signingKeyRingFile: String?
152-
var ossrhUsername: String?
153-
var ossrhPassword: String?
152+
var centralUsername: String?
153+
var centralPassword: String?
154154
var sonatypeStagingProfileId: String?
155155

156156
init {
@@ -171,8 +171,8 @@ class DeployedCredentials(private val project: Project) {
171171
this.signingKeyId = properties.getOrEnvvar("SIGNING_KEY_ID")
172172
this.signingPassword = properties.getOrEnvvar("SIGNING_PASSWORD")
173173
this.signingKeyRingFile = properties.getOrEnvvar("SIGNING_KEY_RING_FILE")
174-
this.ossrhUsername = properties.getOrEnvvar("OSSRH_USERNAME")
175-
this.ossrhPassword = properties.getOrEnvvar("OSSRH_PASSWORD")
174+
this.centralUsername = properties.getOrEnvvar("CENTRAL_USERNAME")
175+
this.centralPassword = properties.getOrEnvvar("CENTRAL_PASSWORD")
176176
this.sonatypeStagingProfileId = properties.getOrEnvvar("SONATYPE_STAGING_PROFILE_ID")
177177
}
178178

instrumentation/.idea/runConfigurations/Instrumentation__Publish_Release_Manually.xml

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/.idea/runConfigurations/Plugin__Publish_Release_Manually.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/.idea/runConfigurations/Plugin__Run_Unit_Tests.xml

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)