Skip to content

Commit a60ab23

Browse files
committed
use gradle-maven-publish-plugin as it creates staging repository itself and doesn't rely on auto-staging
1 parent d94506c commit a60ab23

File tree

5 files changed

+50
-94
lines changed

5 files changed

+50
-94
lines changed

.github/workflows/publish-release.yml

+5-13
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,10 @@ jobs:
1515
with:
1616
cache-disabled: true
1717

18-
- name: Publish to Maven Local (prepare packages)
19-
run: ./gradlew publishToMavenLocal -Pversion=${{ github.ref_name }} --no-configuration-cache
20-
env:
21-
ORG_GRADLE_PROJECT_signingKey: ${{secrets.signingKey}}
22-
ORG_GRADLE_PROJECT_signingPassword: ${{secrets.signingPassword}}
23-
ORG_GRADLE_PROJECT_sonatypeUsername: ${{secrets.sonatypeUsername}}
24-
ORG_GRADLE_PROJECT_sonatypePassword: ${{secrets.sonatypePassword}}
25-
2618
- name: Publish release to Maven Central
27-
run: ./gradlew publishAllPublicationsToMavenCentralRepository -Pversion=${{ github.ref_name }} --no-configuration-cache --no-parallel
19+
run: ./gradlew publishToMavenCentral -Pversion=${{ github.ref_name }} --no-configuration-cache
2820
env:
29-
ORG_GRADLE_PROJECT_signingKey: ${{secrets.signingKey}}
30-
ORG_GRADLE_PROJECT_signingPassword: ${{secrets.signingPassword}}
31-
ORG_GRADLE_PROJECT_sonatypeUsername: ${{secrets.sonatypeUsername}}
32-
ORG_GRADLE_PROJECT_sonatypePassword: ${{secrets.sonatypePassword}}
21+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{secrets.signingKey}}
22+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{secrets.signingPassword}}
23+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{secrets.sonatypeUsername}}
24+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{secrets.sonatypePassword}}

.github/workflows/publish-snapshot.yml

+6-14
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,10 @@ jobs:
1515
with:
1616
cache-disabled: true
1717

18-
- name: Publish to Maven Local (prepare packages)
19-
run: ./gradlew publishToMavenLocal -Pversion=0.4.0-SNAPSHOT --no-configuration-cache
18+
- name: Publish snapshot to Maven Central
19+
run: ./gradlew publishToMavenCentral -Pversion=0.4.0-SNAPSHOT --no-configuration-cache
2020
env:
21-
ORG_GRADLE_PROJECT_signingKey: ${{secrets.signingKey}}
22-
ORG_GRADLE_PROJECT_signingPassword: ${{secrets.signingPassword}}
23-
ORG_GRADLE_PROJECT_sonatypeUsername: ${{secrets.sonatypeUsername}}
24-
ORG_GRADLE_PROJECT_sonatypePassword: ${{secrets.sonatypePassword}}
25-
26-
- name: Publish snapshot to Sonatype
27-
run: ./gradlew publishAllPublicationsToSnapshotRepository -Pversion=0.4.0-SNAPSHOT --no-configuration-cache
28-
env:
29-
ORG_GRADLE_PROJECT_signingKey: ${{secrets.signingKey}}
30-
ORG_GRADLE_PROJECT_signingPassword: ${{secrets.signingPassword}}
31-
ORG_GRADLE_PROJECT_sonatypeUsername: ${{secrets.sonatypeUsername}}
32-
ORG_GRADLE_PROJECT_sonatypePassword: ${{secrets.sonatypePassword}}
21+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{secrets.signingKey}}
22+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{secrets.signingPassword}}
23+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{secrets.sonatypeUsername}}
24+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{secrets.sonatypePassword}}

build-logic/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ dependencies {
1313
implementation(libs.build.kotlin.dokka)
1414
implementation(libs.build.android)
1515
implementation(libs.build.apache.commons.compress)
16+
implementation(libs.maven.publish.gradle.plugin)
1617
implementation("testtool:plugin")
1718
}

build-logic/src/main/kotlin/ckbuild.publication.gradle.kts

+35-67
Original file line numberDiff line numberDiff line change
@@ -2,81 +2,49 @@
22
* Copyright (c) 2023-2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
plugins {
6-
`maven-publish`
7-
signing
8-
}
9-
10-
val sonatypeUsername: String? by project
11-
val sonatypePassword: String? by project
5+
import com.vanniktech.maven.publish.*
126

13-
val signingKey: String? by project
14-
val signingPassword: String? by project
15-
16-
signing {
17-
isRequired = sonatypeUsername != null && sonatypePassword != null
18-
useInMemoryPgpKeys(signingKey, signingPassword)
19-
sign(publishing.publications)
7+
plugins {
8+
id("com.vanniktech.maven.publish.base")
209
}
2110

22-
val javadocJar by tasks.registering(Jar::class) { archiveClassifier.set("javadoc") }
23-
24-
// this is somewhat a hack because we have single javadoc artifact which is used for all publications
25-
tasks.withType<Sign>().configureEach { dependsOn(javadocJar) }
26-
tasks.withType<AbstractPublishToMaven>().configureEach { dependsOn(tasks.withType<Sign>()) }
27-
28-
publishing {
29-
repositories {
30-
maven {
31-
name = "snapshot"
32-
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
33-
credentials {
34-
username = sonatypeUsername
35-
password = sonatypePassword
11+
mavenPublishing {
12+
publishToMavenCentral(SonatypeHost.S01)
13+
signAllPublications()
14+
15+
pom {
16+
name.set(project.name)
17+
description.set(provider {
18+
checkNotNull(project.description) { "Project description isn't set for project: ${project.path}" }
19+
})
20+
url.set("https://github.com/whyoleg/cryptography-kotlin")
21+
22+
licenses {
23+
license {
24+
name.set("The Apache Software License, Version 2.0")
25+
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
26+
distribution.set("repo")
3627
}
3728
}
38-
maven {
39-
name = "mavenCentral"
40-
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
41-
credentials {
42-
username = sonatypeUsername
43-
password = sonatypePassword
29+
developers {
30+
developer {
31+
id.set("whyoleg")
32+
name.set("Oleg Yukhnevich")
33+
email.set("[email protected]")
4434
}
4535
}
46-
maven {
47-
name = "projectLocal"
48-
url = uri(rootProject.layout.buildDirectory.dir("mavenProjectLocal"))
49-
}
50-
}
51-
52-
publications.withType<MavenPublication>().configureEach {
53-
artifact(javadocJar)
54-
pom {
55-
name.set(project.name)
56-
description.set(provider {
57-
checkNotNull(project.description) { "Project description isn't set for project: ${project.path}" }
58-
})
36+
scm {
37+
connection.set("https://github.com/whyoleg/cryptography-kotlin.git")
38+
developerConnection.set("https://github.com/whyoleg/cryptography-kotlin.git")
5939
url.set("https://github.com/whyoleg/cryptography-kotlin")
60-
61-
licenses {
62-
license {
63-
name.set("The Apache Software License, Version 2.0")
64-
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
65-
distribution.set("repo")
66-
}
67-
}
68-
developers {
69-
developer {
70-
id.set("whyoleg")
71-
name.set("Oleg Yukhnevich")
72-
email.set("[email protected]")
73-
}
74-
}
75-
scm {
76-
connection.set("https://github.com/whyoleg/cryptography-kotlin.git")
77-
developerConnection.set("https://github.com/whyoleg/cryptography-kotlin.git")
78-
url.set("https://github.com/whyoleg/cryptography-kotlin")
79-
}
8040
}
8141
}
8242
}
43+
44+
// javadocJar setup
45+
// we have a single javadoc artifact which is used for all publications,
46+
// and so we need to manually create task dependencies to make Gradle happy
47+
val javadocJar by tasks.registering(Jar::class) { archiveClassifier.set("javadoc") }
48+
tasks.withType<Sign>().configureEach { dependsOn(javadocJar) }
49+
tasks.withType<AbstractPublishToMaven>().configureEach { dependsOn(tasks.withType<Sign>()) }
50+
publishing.publications.withType<MavenPublication>().configureEach { artifact(javadocJar) }

gradle/libs.versions.toml

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ gradle-customUserData = "1.12.1"
2020
gradle-foojay = "0.8.0"
2121
buildconfig = "5.3.5"
2222
apache-commons-compress = "1.25.0"
23+
maven-publish = "0.28.0"
2324

2425
# other
2526
bouncycastle = "1.77"
@@ -39,6 +40,8 @@ build-gradle-foojay = { module = "org.gradle.toolchains:foojay-resolver", versio
3940

4041
build-apache-commons-compress = { module = "org.apache.commons:commons-compress", version.ref = "apache-commons-compress" }
4142

43+
maven-publish-gradle-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "maven-publish" }
44+
4245
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
4346
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
4447
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" }

0 commit comments

Comments
 (0)