Skip to content

Commit 422d8f0

Browse files
Maven relocation (follow-up) (pinterest#2313)
* Update how-to for testing signing of artifacts on local machine * Publish "all" publications (both maven and relocation publications) to MavenCentral * Add metadata and repository information to relocations poms
1 parent 0947c61 commit 422d8f0

File tree

13 files changed

+412
-44
lines changed

13 files changed

+412
-44
lines changed

.github/workflows/publish-release-build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ jobs:
1515
with:
1616
ref: 'master'
1717

18-
1918
- uses: ./.github/actions/setup-gradle-build
2019

2120
- name: Build executable and publish to Maven
22-
run: ./gradlew clean shadowJarExecutable publishMavenPublicationToMavenCentralRepository --no-daemon --no-parallel --no-configuration-cache
21+
run: ./gradlew clean shadowJarExecutable publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel --no-configuration-cache
2322
env:
2423
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
2524
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}

.github/workflows/publish-snapshot-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: ./.github/actions/setup-gradle-build
2020

2121
- name: Publish snapshot to Maven
22-
run: ./gradlew clean publishMavenPublicationToMavenCentralRepository --no-daemon --no-parallel --no-configuration-cache
22+
run: ./gradlew clean publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel --no-configuration-cache
2323

2424
- name: Publish Kotlin-dev snapshot to Maven
2525
run: ./gradlew -PkotlinDev clean publishMavenPublicationToMavenCentralRepository --no-daemon --no-parallel --no-configuration-cache

SIGNING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ To test the creation of signed artifacts on the local machine, follow steps belo
2626
export ORG_GRADLE_PROJECT_signingKeyId="63A5D3C3" # Last 8 characters of full id of the public key generated by gpg command above
2727
export ORG_GRADLE_PROJECT_signingKeyPassword="i-will-try-no-to-forget-this-passphrase"
2828
# Command below will export the armored GPG signing key and store it in an environment variable. Note that this command will ask for the password (see ORG_GRADLE_PROJECT_signingKeyPassword).
29-
export ORG_GRADLE_PROJECT_signingKey="$(gpg --export-secret-keys --armor $GPG_FULL_KEY_ID | tail -r | tail -n +3 | tail -r | tail -n +3 | tr -d '\n')"
29+
export ORG_GRADLE_PROJECT_signingKey="$(gpg --export-secret-keys --armor $ORG_GRADLE_PROJECT_signingKeyId | tail -r | tail -n +3 | tail -r | tail -n +3 | tr -d '\n')"
3030
```
3131
* Execute the Gradle publication (this can not be combined with the export statements above because of the manual input of the passphrase)
3232
```

ktlint-cli-reporter-baseline/build.gradle.kts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.net.URI
2+
13
plugins {
24
id("ktlint-publication-library")
35
}
@@ -20,6 +22,28 @@ publishing {
2022
artifactId = "ktlint-reporter-baseline"
2123
version = "0.51.0-FINAL"
2224

25+
name = artifactId
26+
description = providers.gradleProperty("POM_DESCRIPTION")
27+
url = providers.gradleProperty("POM_URL")
28+
licenses {
29+
license {
30+
name = providers.gradleProperty("POM_LICENSE_NAME")
31+
url = providers.gradleProperty("POM_LICENSE_URL")
32+
distribution = "repo"
33+
}
34+
}
35+
developers {
36+
developer {
37+
id = providers.gradleProperty("POM_DEVELOPER_ID")
38+
name = providers.gradleProperty("POM_DEVELOPER_NAME")
39+
}
40+
}
41+
scm {
42+
url = providers.gradleProperty("POM_SCM_URL")
43+
connection = providers.gradleProperty("POM_SCM_CONNECTION")
44+
developerConnection = providers.gradleProperty("POM_SCM_DEV_CONNECTION")
45+
}
46+
2347
distributionManagement {
2448
relocation {
2549
// New artifact coordinates
@@ -28,6 +52,22 @@ publishing {
2852
message.set("artifactId has been changed")
2953
}
3054
}
55+
56+
repositories {
57+
maven {
58+
val releasesRepoUrl = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
59+
val snapshotsRepoUrl = URI.create("https://oss.sonatype.org/content/repositories/snapshots/")
60+
name = "mavenCentral"
61+
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
62+
63+
credentials {
64+
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
65+
?: System.getenv("SONATYPE_NEXUS_USERNAME")
66+
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
67+
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
68+
}
69+
}
70+
}
3171
}
3272
}
3373
}
@@ -44,10 +84,7 @@ signing {
4484
val signingPassword = System.getenv("ORG_GRADLE_PROJECT_signingKeyPassword")
4585
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
4686

47-
// This property allows OS package maintainers to disable signing
48-
val enableSigning = providers.gradleProperty("ktlint.publication.signing.enable").orNull != "false"
49-
5087
sign(publishing.publications["relocation-ktlint-cli-reporter-baseline"])
5188

52-
isRequired = enableSigning && !version.toString().endsWith("SNAPSHOT")
89+
isRequired = true
5390
}

ktlint-cli-reporter-checkstyle/build.gradle.kts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.net.URI
2+
13
plugins {
24
id("ktlint-publication-library")
35
}
@@ -18,6 +20,28 @@ publishing {
1820
artifactId = "ktlint-reporter-checkstyle"
1921
version = "0.51.0-FINAL"
2022

23+
name = artifactId
24+
description = providers.gradleProperty("POM_DESCRIPTION")
25+
url = providers.gradleProperty("POM_URL")
26+
licenses {
27+
license {
28+
name = providers.gradleProperty("POM_LICENSE_NAME")
29+
url = providers.gradleProperty("POM_LICENSE_URL")
30+
distribution = "repo"
31+
}
32+
}
33+
developers {
34+
developer {
35+
id = providers.gradleProperty("POM_DEVELOPER_ID")
36+
name = providers.gradleProperty("POM_DEVELOPER_NAME")
37+
}
38+
}
39+
scm {
40+
url = providers.gradleProperty("POM_SCM_URL")
41+
connection = providers.gradleProperty("POM_SCM_CONNECTION")
42+
developerConnection = providers.gradleProperty("POM_SCM_DEV_CONNECTION")
43+
}
44+
2145
distributionManagement {
2246
relocation {
2347
// New artifact coordinates
@@ -26,6 +50,22 @@ publishing {
2650
message.set("artifactId has been changed")
2751
}
2852
}
53+
54+
repositories {
55+
maven {
56+
val releasesRepoUrl = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
57+
val snapshotsRepoUrl = URI.create("https://oss.sonatype.org/content/repositories/snapshots/")
58+
name = "mavenCentral"
59+
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
60+
61+
credentials {
62+
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
63+
?: System.getenv("SONATYPE_NEXUS_USERNAME")
64+
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
65+
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
66+
}
67+
}
68+
}
2969
}
3070
}
3171
}
@@ -42,10 +82,7 @@ signing {
4282
val signingPassword = System.getenv("ORG_GRADLE_PROJECT_signingKeyPassword")
4383
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
4484

45-
// This property allows OS package maintainers to disable signing
46-
val enableSigning = providers.gradleProperty("ktlint.publication.signing.enable").orNull != "false"
47-
4885
sign(publishing.publications["relocation-ktlint-cli-reporter-checkstyle"])
4986

50-
isRequired = enableSigning && !version.toString().endsWith("SNAPSHOT")
87+
isRequired = true
5188
}

ktlint-cli-reporter-core/build.gradle.kts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.net.URI
2+
13
plugins {
24
id("ktlint-publication-library")
35
}
@@ -12,6 +14,28 @@ publishing {
1214
artifactId = "ktlint-cli-reporter"
1315
version = "0.51.0-FINAL"
1416

17+
name = artifactId
18+
description = providers.gradleProperty("POM_DESCRIPTION")
19+
url = providers.gradleProperty("POM_URL")
20+
licenses {
21+
license {
22+
name = providers.gradleProperty("POM_LICENSE_NAME")
23+
url = providers.gradleProperty("POM_LICENSE_URL")
24+
distribution = "repo"
25+
}
26+
}
27+
developers {
28+
developer {
29+
id = providers.gradleProperty("POM_DEVELOPER_ID")
30+
name = providers.gradleProperty("POM_DEVELOPER_NAME")
31+
}
32+
}
33+
scm {
34+
url = providers.gradleProperty("POM_SCM_URL")
35+
connection = providers.gradleProperty("POM_SCM_CONNECTION")
36+
developerConnection = providers.gradleProperty("POM_SCM_DEV_CONNECTION")
37+
}
38+
1539
distributionManagement {
1640
relocation {
1741
// New artifact coordinates
@@ -20,6 +44,22 @@ publishing {
2044
message.set("artifactId has been changed")
2145
}
2246
}
47+
48+
repositories {
49+
maven {
50+
val releasesRepoUrl = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
51+
val snapshotsRepoUrl = URI.create("https://oss.sonatype.org/content/repositories/snapshots/")
52+
name = "mavenCentral"
53+
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
54+
55+
credentials {
56+
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
57+
?: System.getenv("SONATYPE_NEXUS_USERNAME")
58+
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
59+
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
60+
}
61+
}
62+
}
2363
}
2464
}
2565
}
@@ -36,10 +76,7 @@ signing {
3676
val signingPassword = System.getenv("ORG_GRADLE_PROJECT_signingKeyPassword")
3777
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
3878

39-
// This property allows OS package maintainers to disable signing
40-
val enableSigning = providers.gradleProperty("ktlint.publication.signing.enable").orNull != "false"
41-
4279
sign(publishing.publications["relocation-ktlint-cli-reporter-core"])
4380

44-
isRequired = enableSigning && !version.toString().endsWith("SNAPSHOT")
81+
isRequired = true
4582
}

ktlint-cli-reporter-format/build.gradle.kts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.net.URI
2+
13
plugins {
24
id("ktlint-publication-library")
35
}
@@ -18,6 +20,28 @@ publishing {
1820
artifactId = "ktlint-reporter-format"
1921
version = "0.51.0-FINAL"
2022

23+
name = artifactId
24+
description = providers.gradleProperty("POM_DESCRIPTION")
25+
url = providers.gradleProperty("POM_URL")
26+
licenses {
27+
license {
28+
name = providers.gradleProperty("POM_LICENSE_NAME")
29+
url = providers.gradleProperty("POM_LICENSE_URL")
30+
distribution = "repo"
31+
}
32+
}
33+
developers {
34+
developer {
35+
id = providers.gradleProperty("POM_DEVELOPER_ID")
36+
name = providers.gradleProperty("POM_DEVELOPER_NAME")
37+
}
38+
}
39+
scm {
40+
url = providers.gradleProperty("POM_SCM_URL")
41+
connection = providers.gradleProperty("POM_SCM_CONNECTION")
42+
developerConnection = providers.gradleProperty("POM_SCM_DEV_CONNECTION")
43+
}
44+
2145
distributionManagement {
2246
relocation {
2347
// New artifact coordinates
@@ -26,6 +50,22 @@ publishing {
2650
message.set("artifactId has been changed")
2751
}
2852
}
53+
54+
repositories {
55+
maven {
56+
val releasesRepoUrl = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
57+
val snapshotsRepoUrl = URI.create("https://oss.sonatype.org/content/repositories/snapshots/")
58+
name = "mavenCentral"
59+
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
60+
61+
credentials {
62+
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
63+
?: System.getenv("SONATYPE_NEXUS_USERNAME")
64+
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
65+
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
66+
}
67+
}
68+
}
2969
}
3070
}
3171
}
@@ -42,10 +82,7 @@ signing {
4282
val signingPassword = System.getenv("ORG_GRADLE_PROJECT_signingKeyPassword")
4383
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
4484

45-
// This property allows OS package maintainers to disable signing
46-
val enableSigning = providers.gradleProperty("ktlint.publication.signing.enable").orNull != "false"
47-
4885
sign(publishing.publications["relocation-ktlint-cli-reporter-format"])
4986

50-
isRequired = enableSigning && !version.toString().endsWith("SNAPSHOT")
87+
isRequired = true
5188
}

ktlint-cli-reporter-html/build.gradle.kts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.net.URI
2+
13
plugins {
24
id("ktlint-publication-library")
35
}
@@ -18,6 +20,28 @@ publishing {
1820
artifactId = "ktlint-reporter-html"
1921
version = "0.51.0-FINAL"
2022

23+
name = artifactId
24+
description = providers.gradleProperty("POM_DESCRIPTION")
25+
url = providers.gradleProperty("POM_URL")
26+
licenses {
27+
license {
28+
name = providers.gradleProperty("POM_LICENSE_NAME")
29+
url = providers.gradleProperty("POM_LICENSE_URL")
30+
distribution = "repo"
31+
}
32+
}
33+
developers {
34+
developer {
35+
id = providers.gradleProperty("POM_DEVELOPER_ID")
36+
name = providers.gradleProperty("POM_DEVELOPER_NAME")
37+
}
38+
}
39+
scm {
40+
url = providers.gradleProperty("POM_SCM_URL")
41+
connection = providers.gradleProperty("POM_SCM_CONNECTION")
42+
developerConnection = providers.gradleProperty("POM_SCM_DEV_CONNECTION")
43+
}
44+
2145
distributionManagement {
2246
relocation {
2347
// New artifact coordinates
@@ -26,6 +50,22 @@ publishing {
2650
message.set("artifactId has been changed")
2751
}
2852
}
53+
54+
repositories {
55+
maven {
56+
val releasesRepoUrl = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
57+
val snapshotsRepoUrl = URI.create("https://oss.sonatype.org/content/repositories/snapshots/")
58+
name = "mavenCentral"
59+
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
60+
61+
credentials {
62+
username = providers.gradleProperty("SONATYPE_NEXUS_USERNAME").orNull
63+
?: System.getenv("SONATYPE_NEXUS_USERNAME")
64+
password = providers.gradleProperty("SONATYPE_NEXUS_PASSWORD").orNull
65+
?: System.getenv("SONATYPE_NEXUS_PASSWORD")
66+
}
67+
}
68+
}
2969
}
3070
}
3171
}
@@ -42,10 +82,7 @@ signing {
4282
val signingPassword = System.getenv("ORG_GRADLE_PROJECT_signingKeyPassword")
4383
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
4484

45-
// This property allows OS package maintainers to disable signing
46-
val enableSigning = providers.gradleProperty("ktlint.publication.signing.enable").orNull != "false"
47-
4885
sign(publishing.publications["relocation-ktlint-cli-reporter-html"])
4986

50-
isRequired = enableSigning && !version.toString().endsWith("SNAPSHOT")
87+
isRequired = true
5188
}

0 commit comments

Comments
 (0)