Skip to content

Commit

Permalink
Add maven relocation (#2282)
Browse files Browse the repository at this point in the history
In the `1.0.0` release, the maven coordinates of some modules were changed. To support migration to the new coordinates a special relocatation `pom.xml`s (with version `0.51.0-FINAL`) are created. Builds running on a release up until `0.50.x` that will upgrade to the `0.51.0-FINAL` release will then get a message with the new maven coordinates.

Closes #2280
  • Loading branch information
paul-dingemans authored Oct 13, 2023
1 parent 04dde90 commit 2acdeeb
Show file tree
Hide file tree
Showing 11 changed files with 455 additions and 0 deletions.
34 changes: 34 additions & 0 deletions SIGNING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Release artifacts are signed. This is handled by the GitHub workflow.

To test the creation of signed artifacts on the local machine, follow steps below:

* Change property `VERSION_NAME` in `gradle.properties` so that it does not end with `-SNAPSHOT`. Whenever the version ends with `-SNAPSHOT`, the artifacts are never signed. Make sure that this change is not committed.
* Use [GPG](https://infra.apache.org/openpgp.html#key-gen-generate-key) to generate a key. Maven requires a RSA key of at least 4096 bits. Most likely it does not matter for local publication whether this is used. Execute command:
```
gpg --full-gen-key
```
* Please select what kind of key you want: 1) RSA - RSA
* What keysize do you want? 4096
* Key is valid for? 0 (does not expire)
* Real-name: ktlint-test
* Email address: ktlint-test@nowhere.com
* Comment: Test signing of ktlint artifacts on local machine only
* Passphrase: i-will-try-no-to-forget-this-passphrase
* The output ends with something like
```text
pub rsa4096 2023-10-08 [SC]
5B0ABB03277D2FEB46FE7E8E22D6006063A5D3C3
uid ktlint-test (Test signing of ktlint artifacts on local machine only) <ktlint-test@nowhere.com>
sub rsa4096 2023-10-08 [E]
```
* Execute all commands below in the same terminal
```shell
export ORG_GRADLE_PROJECT_signingKeyId="63A5D3C3" # Last 8 characters of full id of the public key generated by gpg command above
export ORG_GRADLE_PROJECT_signingKeyPassword="i-will-try-no-to-forget-this-passphrase"
# 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).
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')"
```
* Execute the Gradle publication (this can not be combined with the export statements above because of the manual input of the passphrase)
```
./gradlew publishToMavenLocal
```
42 changes: 42 additions & 0 deletions ktlint-cli-reporter-baseline/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,45 @@ dependencies {

testImplementation(projects.ktlintTest)
}

// TODO: Remove in release after ktlint 1.0.1
publishing {
publications {
create<MavenPublication>("relocation-ktlint-cli-reporter-baseline") {
pom {
// Old artifact coordinates
groupId = "com.pinterest.ktlint"
artifactId = "ktlint-reporter-baseline"
version = "0.51.0-FINAL"

distributionManagement {
relocation {
// New artifact coordinates
artifactId.set("ktlint-cli-reporter-baseline")
version.set("1.0.0")
message.set("artifactId has been changed")
}
}
}
}
}
}

// TODO: Remove in release after ktlint 1.0.1
signing {
// Uncomment following line to use gpg-agent for signing
// See https://docs.gradle.org/current/userguide/signing_plugin.html#sec:using_gpg_agent how to configure it
// useGpgCmd()

val signingKeyId = System.getenv("ORG_GRADLE_PROJECT_signingKeyId")
val signingKey = System.getenv("ORG_GRADLE_PROJECT_signingKey")
val signingPassword = System.getenv("ORG_GRADLE_PROJECT_signingKeyPassword")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)

// This property allows OS package maintainers to disable signing
val enableSigning = providers.gradleProperty("ktlint.publication.signing.enable").orNull != "false"

sign(publishing.publications["relocation-ktlint-cli-reporter-baseline"])

isRequired = enableSigning && !version.toString().endsWith("SNAPSHOT")
}
42 changes: 42 additions & 0 deletions ktlint-cli-reporter-checkstyle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,45 @@ dependencies {

testImplementation(projects.ktlintTest)
}

// TODO: Remove in release after ktlint 1.0.1
publishing {
publications {
create<MavenPublication>("relocation-ktlint-cli-reporter-checkstyle") {
pom {
// Old artifact coordinates
groupId = "com.pinterest.ktlint"
artifactId = "ktlint-reporter-checkstyle"
version = "0.51.0-FINAL"

distributionManagement {
relocation {
// New artifact coordinates
artifactId.set("ktlint-cli-reporter-checkstyle")
version.set("1.0.0")
message.set("artifactId has been changed")
}
}
}
}
}
}

// TODO: Remove in release after ktlint 1.0.1
signing {
// Uncomment following line to use gpg-agent for signing
// See https://docs.gradle.org/current/userguide/signing_plugin.html#sec:using_gpg_agent how to configure it
// useGpgCmd()

val signingKeyId = System.getenv("ORG_GRADLE_PROJECT_signingKeyId")
val signingKey = System.getenv("ORG_GRADLE_PROJECT_signingKey")
val signingPassword = System.getenv("ORG_GRADLE_PROJECT_signingKeyPassword")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)

// This property allows OS package maintainers to disable signing
val enableSigning = providers.gradleProperty("ktlint.publication.signing.enable").orNull != "false"

sign(publishing.publications["relocation-ktlint-cli-reporter-checkstyle"])

isRequired = enableSigning && !version.toString().endsWith("SNAPSHOT")
}
42 changes: 42 additions & 0 deletions ktlint-cli-reporter-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
plugins {
id("ktlint-publication-library")
}

// TODO: Remove in release after ktlint 1.0.1
publishing {
publications {
create<MavenPublication>("relocation-ktlint-cli-reporter-core") {
pom {
// Old artifact coordinates
groupId = "com.pinterest.ktlint"
artifactId = "ktlint-cli-reporter"
version = "0.51.0-FINAL"

distributionManagement {
relocation {
// New artifact coordinates
artifactId.set("ktlint-cli-reporter-core")
version.set("1.0.0")
message.set("artifactId has been changed")
}
}
}
}
}
}

// TODO: Remove in release after ktlint 1.0.1
signing {
// Uncomment following line to use gpg-agent for signing
// See https://docs.gradle.org/current/userguide/signing_plugin.html#sec:using_gpg_agent how to configure it
// useGpgCmd()

val signingKeyId = System.getenv("ORG_GRADLE_PROJECT_signingKeyId")
val signingKey = System.getenv("ORG_GRADLE_PROJECT_signingKey")
val signingPassword = System.getenv("ORG_GRADLE_PROJECT_signingKeyPassword")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)

// This property allows OS package maintainers to disable signing
val enableSigning = providers.gradleProperty("ktlint.publication.signing.enable").orNull != "false"

sign(publishing.publications["relocation-ktlint-cli-reporter-core"])

isRequired = enableSigning && !version.toString().endsWith("SNAPSHOT")
}
42 changes: 42 additions & 0 deletions ktlint-cli-reporter-format/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,45 @@ dependencies {

testImplementation(projects.ktlintTest)
}

// TODO: Remove in release after ktlint 1.0.1
publishing {
publications {
create<MavenPublication>("relocation-ktlint-cli-reporter-format") {
pom {
// Old artifact coordinates
groupId = "com.pinterest.ktlint"
artifactId = "ktlint-reporter-format"
version = "0.51.0-FINAL"

distributionManagement {
relocation {
// New artifact coordinates
artifactId.set("ktlint-cli-reporter-format")
version.set("1.0.0")
message.set("artifactId has been changed")
}
}
}
}
}
}

// TODO: Remove in release after ktlint 1.0.1
signing {
// Uncomment following line to use gpg-agent for signing
// See https://docs.gradle.org/current/userguide/signing_plugin.html#sec:using_gpg_agent how to configure it
// useGpgCmd()

val signingKeyId = System.getenv("ORG_GRADLE_PROJECT_signingKeyId")
val signingKey = System.getenv("ORG_GRADLE_PROJECT_signingKey")
val signingPassword = System.getenv("ORG_GRADLE_PROJECT_signingKeyPassword")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)

// This property allows OS package maintainers to disable signing
val enableSigning = providers.gradleProperty("ktlint.publication.signing.enable").orNull != "false"

sign(publishing.publications["relocation-ktlint-cli-reporter-format"])

isRequired = enableSigning && !version.toString().endsWith("SNAPSHOT")
}
42 changes: 42 additions & 0 deletions ktlint-cli-reporter-html/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,45 @@ dependencies {

testImplementation(projects.ktlintTest)
}

// TODO: Remove in release after ktlint 1.0.1
publishing {
publications {
create<MavenPublication>("relocation-ktlint-cli-reporter-html") {
pom {
// Old artifact coordinates
groupId = "com.pinterest.ktlint"
artifactId = "ktlint-reporter-html"
version = "0.51.0-FINAL"

distributionManagement {
relocation {
// New artifact coordinates
artifactId.set("ktlint-cli-reporter-html")
version.set("1.0.0")
message.set("artifactId has been changed")
}
}
}
}
}
}

// TODO: Remove in release after ktlint 1.0.1
signing {
// Uncomment following line to use gpg-agent for signing
// See https://docs.gradle.org/current/userguide/signing_plugin.html#sec:using_gpg_agent how to configure it
// useGpgCmd()

val signingKeyId = System.getenv("ORG_GRADLE_PROJECT_signingKeyId")
val signingKey = System.getenv("ORG_GRADLE_PROJECT_signingKey")
val signingPassword = System.getenv("ORG_GRADLE_PROJECT_signingKeyPassword")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)

// This property allows OS package maintainers to disable signing
val enableSigning = providers.gradleProperty("ktlint.publication.signing.enable").orNull != "false"

sign(publishing.publications["relocation-ktlint-cli-reporter-html"])

isRequired = enableSigning && !version.toString().endsWith("SNAPSHOT")
}
42 changes: 42 additions & 0 deletions ktlint-cli-reporter-json/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,45 @@ dependencies {

testImplementation(projects.ktlintTest)
}

// TODO: Remove in release after ktlint 1.0.1
publishing {
publications {
create<MavenPublication>("relocation-ktlint-cli-reporter-json") {
pom {
// Old artifact coordinates
groupId = "com.pinterest.ktlint"
artifactId = "ktlint-reporter-json"
version = "0.51.0-FINAL"

distributionManagement {
relocation {
// New artifact coordinates
artifactId.set("ktlint-cli-reporter-json")
version.set("1.0.0")
message.set("artifactId has been changed")
}
}
}
}
}
}

// TODO: Remove in release after ktlint 1.0.1
signing {
// Uncomment following line to use gpg-agent for signing
// See https://docs.gradle.org/current/userguide/signing_plugin.html#sec:using_gpg_agent how to configure it
// useGpgCmd()

val signingKeyId = System.getenv("ORG_GRADLE_PROJECT_signingKeyId")
val signingKey = System.getenv("ORG_GRADLE_PROJECT_signingKey")
val signingPassword = System.getenv("ORG_GRADLE_PROJECT_signingKeyPassword")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)

// This property allows OS package maintainers to disable signing
val enableSigning = providers.gradleProperty("ktlint.publication.signing.enable").orNull != "false"

sign(publishing.publications["relocation-ktlint-cli-reporter-json"])

isRequired = enableSigning && !version.toString().endsWith("SNAPSHOT")
}
42 changes: 42 additions & 0 deletions ktlint-cli-reporter-plain-summary/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,45 @@ dependencies {

testImplementation(projects.ktlintTest)
}

// TODO: Remove in release after ktlint 1.0.1
publishing {
publications {
create<MavenPublication>("relocation-ktlint-cli-reporter-plain-summary") {
pom {
// Old artifact coordinates
groupId = "com.pinterest.ktlint"
artifactId = "ktlint-reporter-plain-summary"
version = "0.51.0-FINAL"

distributionManagement {
relocation {
// New artifact coordinates
artifactId.set("ktlint-cli-reporter-plain-summary")
version.set("1.0.0")
message.set("artifactId has been changed")
}
}
}
}
}
}

// TODO: Remove in release after ktlint 1.0.1
signing {
// Uncomment following line to use gpg-agent for signing
// See https://docs.gradle.org/current/userguide/signing_plugin.html#sec:using_gpg_agent how to configure it
// useGpgCmd()

val signingKeyId = System.getenv("ORG_GRADLE_PROJECT_signingKeyId")
val signingKey = System.getenv("ORG_GRADLE_PROJECT_signingKey")
val signingPassword = System.getenv("ORG_GRADLE_PROJECT_signingKeyPassword")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)

// This property allows OS package maintainers to disable signing
val enableSigning = providers.gradleProperty("ktlint.publication.signing.enable").orNull != "false"

sign(publishing.publications["relocation-ktlint-cli-reporter-plain-summary"])

isRequired = enableSigning && !version.toString().endsWith("SNAPSHOT")
}
Loading

0 comments on commit 2acdeeb

Please sign in to comment.