From 5e6151751a8116a8c3227a62195acf0c3ca0bcaa Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Sat, 23 Apr 2022 15:13:14 +0100 Subject: [PATCH 1/4] Cleanup Gradle Plugin Pubblications --- .github/workflows/pre-merge.yaml | 4 ++ .../src/main/kotlin/packaging.gradle.kts | 49 ++++++++++--------- build.gradle.kts | 30 ++++++++++++ detekt-gradle-plugin/build.gradle.kts | 3 -- scripts/release.sh | 5 +- 5 files changed, 62 insertions(+), 29 deletions(-) diff --git a/.github/workflows/pre-merge.yaml b/.github/workflows/pre-merge.yaml index d4405ed279e..8e1e0428e19 100644 --- a/.github/workflows/pre-merge.yaml +++ b/.github/workflows/pre-merge.yaml @@ -51,6 +51,10 @@ jobs: uses: gradle/gradle-build-action@v2 with: arguments: :detekt-cli:runWithArgsFile + - name: Try to publish everything to Maven Local + uses: gradle/gradle-build-action@v2 + with: + arguments: publishAllToMavenLocal verify-generated-config-file: if: ${{ !contains(github.event.head_commit.message, 'ci skip') }} diff --git a/build-logic/src/main/kotlin/packaging.gradle.kts b/build-logic/src/main/kotlin/packaging.gradle.kts index 2fe59b080a3..bf458d9b7ba 100644 --- a/build-logic/src/main/kotlin/packaging.gradle.kts +++ b/build-logic/src/main/kotlin/packaging.gradle.kts @@ -27,31 +27,34 @@ publishing { } } } - publications.register(DETEKT_PUBLICATION) { - groupId = "io.gitlab.arturbosch.detekt" - artifactId = project.name - from(components["java"]) - version = Versions.currentOrSnapshot() - pom { - description.set("Static code analysis for Kotlin") - name.set("detekt") - url.set("https://detekt.dev") - licenses { - license { - name.set("The Apache Software License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - distribution.set("repo") + // We don't need to configure publishing for the Gradle plugin. + if (project.name != "detekt-gradle-plugin") { + publications.register(DETEKT_PUBLICATION) { + groupId = "io.gitlab.arturbosch.detekt" + artifactId = project.name + from(components["java"]) + version = Versions.currentOrSnapshot() + pom { + description.set("Static code analysis for Kotlin") + name.set("detekt") + url.set("https://detekt.dev") + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + } } - } - developers { - developer { - id.set("Artur Bosch") - name.set("Artur Bosch") - email.set("arturbosch@gmx.de") + developers { + developer { + id.set("Artur Bosch") + name.set("Artur Bosch") + email.set("arturbosch@gmx.de") + } + } + scm { + url.set("https://github.com/detekt/detekt") } - } - scm { - url.set("https://github.com/detekt/detekt") } } } diff --git a/build.gradle.kts b/build.gradle.kts index 588ef8ee389..4c3445a56b4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -109,3 +109,33 @@ val detektProjectBaseline by tasks.registering(DetektCreateBaselineTask::class) tasks.register("build") { dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":build")) } + +tasks.register("publishAllToMavenLocal") { + description = "Publish all the projects to Maven Local" + subprojects { + if (this.plugins.hasPlugin("publishing")) { + dependsOn(tasks.named("publishToMavenLocal")) + } + } + dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":publishToMavenLocal")) +} + +tasks.register("publishAllToSonatypeSnapshot") { + description = "Publish all the projects to Sonatype Snapshot Repository" + subprojects { + if (this.plugins.hasPlugin("publishing")) { + dependsOn(tasks.named("publishAllPublicationsToSonatypeSnapshotRepository")) + } + } + dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":publishAllPublicationsToSonatypeSnapshotRepository")) +} + +tasks.register("publishAllToMavenCentral") { + description = "Publish all the projects to Sonatype Staging Repository" + subprojects { + if (this.plugins.hasPlugin("publishing")) { + dependsOn(tasks.named("publishAllPublicationsToMavenCentralRepository")) + } + } + dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":publishAllPublicationsToMavenCentralRepository")) +} diff --git a/detekt-gradle-plugin/build.gradle.kts b/detekt-gradle-plugin/build.gradle.kts index c7093a15419..09086d71120 100644 --- a/detekt-gradle-plugin/build.gradle.kts +++ b/detekt-gradle-plugin/build.gradle.kts @@ -75,9 +75,6 @@ dependencies { } gradlePlugin { - // hack to prevent building two jar's overwriting each other and leading to invalid signatures - // when publishing the Gradle plugin, this property must be present - isAutomatedPublishing = System.getProperty("automatePublishing")?.toBoolean() ?: false plugins { register("detektPlugin") { id = "io.gitlab.arturbosch.detekt" diff --git a/scripts/release.sh b/scripts/release.sh index c7eebb2e26d..bc06f7d4200 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,8 +1,7 @@ #!/usr/bin/env sh -gradle build publishToMavenLocal -x detekt -x test || exit gradle build || exit -gradle publishAllPublicationsToMavenCentralRepository --max-workers 1 || exit -gradle publishPlugins -DautomatePublishing=true || exit +gradle publishAllToMavenCentral --max-workers 1 || exit +gradle publishPlugins || exit gradle githubRelease || exit gradle applyDocVersion || exit gradle closeAndReleaseRepository || exit From d1dbf6b522e21cb0f8809a15fc7c0341d5ad6f83 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Sun, 24 Apr 2022 13:22:30 +0100 Subject: [PATCH 2/4] Address review feedback --- .../src/main/kotlin/packaging.gradle.kts | 8 ++--- .../src/main/kotlin/releasing.gradle.kts | 30 +++++++++++++++++++ build.gradle.kts | 30 ------------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/build-logic/src/main/kotlin/packaging.gradle.kts b/build-logic/src/main/kotlin/packaging.gradle.kts index bf458d9b7ba..cef85110f42 100644 --- a/build-logic/src/main/kotlin/packaging.gradle.kts +++ b/build-logic/src/main/kotlin/packaging.gradle.kts @@ -41,15 +41,15 @@ publishing { licenses { license { name.set("The Apache Software License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") distribution.set("repo") } } developers { developer { - id.set("Artur Bosch") - name.set("Artur Bosch") - email.set("arturbosch@gmx.de") + id.set("Detekt Developers") + name.set("Detekt Developers") + email.set("info@detekt.dev") } } scm { diff --git a/build-logic/src/main/kotlin/releasing.gradle.kts b/build-logic/src/main/kotlin/releasing.gradle.kts index 0a38fb6e322..b3835623045 100644 --- a/build-logic/src/main/kotlin/releasing.gradle.kts +++ b/build-logic/src/main/kotlin/releasing.gradle.kts @@ -70,3 +70,33 @@ tasks { lineTransformation.set(" detektVersion: '${Versions.DETEKT}'") } } + +tasks.register("publishToMavenLocal") { + description = "Publish all the projects to Maven Local" + subprojects { + if (this.plugins.hasPlugin("publishing")) { + dependsOn(tasks.named("publishToMavenLocal")) + } + } + dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":publishToMavenLocal")) +} + +tasks.register("publishAllToSonatypeSnapshot") { + description = "Publish all the projects to Sonatype Snapshot Repository" + subprojects { + if (this.plugins.hasPlugin("publishing")) { + dependsOn(tasks.named("publishAllPublicationsToSonatypeSnapshotRepository")) + } + } + dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":publishAllPublicationsToSonatypeSnapshotRepository")) +} + +tasks.register("publishAllToMavenCentral") { + description = "Publish all the projects to Sonatype Staging Repository" + subprojects { + if (this.plugins.hasPlugin("publishing")) { + dependsOn(tasks.named("publishAllPublicationsToMavenCentralRepository")) + } + } + dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":publishAllPublicationsToMavenCentralRepository")) +} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 4c3445a56b4..588ef8ee389 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -109,33 +109,3 @@ val detektProjectBaseline by tasks.registering(DetektCreateBaselineTask::class) tasks.register("build") { dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":build")) } - -tasks.register("publishAllToMavenLocal") { - description = "Publish all the projects to Maven Local" - subprojects { - if (this.plugins.hasPlugin("publishing")) { - dependsOn(tasks.named("publishToMavenLocal")) - } - } - dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":publishToMavenLocal")) -} - -tasks.register("publishAllToSonatypeSnapshot") { - description = "Publish all the projects to Sonatype Snapshot Repository" - subprojects { - if (this.plugins.hasPlugin("publishing")) { - dependsOn(tasks.named("publishAllPublicationsToSonatypeSnapshotRepository")) - } - } - dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":publishAllPublicationsToSonatypeSnapshotRepository")) -} - -tasks.register("publishAllToMavenCentral") { - description = "Publish all the projects to Sonatype Staging Repository" - subprojects { - if (this.plugins.hasPlugin("publishing")) { - dependsOn(tasks.named("publishAllPublicationsToMavenCentralRepository")) - } - } - dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":publishAllPublicationsToMavenCentralRepository")) -} From eabe29f6307297237f97d4d878545d675716b3f9 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 26 Apr 2022 11:53:16 +0100 Subject: [PATCH 3/4] Add mising \n --- build-logic/src/main/kotlin/releasing.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-logic/src/main/kotlin/releasing.gradle.kts b/build-logic/src/main/kotlin/releasing.gradle.kts index b3835623045..0c9aec26605 100644 --- a/build-logic/src/main/kotlin/releasing.gradle.kts +++ b/build-logic/src/main/kotlin/releasing.gradle.kts @@ -99,4 +99,4 @@ tasks.register("publishAllToMavenCentral") { } } dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":publishAllPublicationsToMavenCentralRepository")) -} \ No newline at end of file +} From 1ae7ba23d6d108d241ad156de17d8c42aee2182b Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 26 Apr 2022 12:07:10 +0100 Subject: [PATCH 4/4] publishAllToMavenLocal -> publishToMavenLocal --- .github/workflows/pre-merge.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pre-merge.yaml b/.github/workflows/pre-merge.yaml index 8e1e0428e19..f581cf54aea 100644 --- a/.github/workflows/pre-merge.yaml +++ b/.github/workflows/pre-merge.yaml @@ -51,10 +51,10 @@ jobs: uses: gradle/gradle-build-action@v2 with: arguments: :detekt-cli:runWithArgsFile - - name: Try to publish everything to Maven Local + - name: Try to publish to Maven Local uses: gradle/gradle-build-action@v2 with: - arguments: publishAllToMavenLocal + arguments: publishToMavenLocal verify-generated-config-file: if: ${{ !contains(github.event.head_commit.message, 'ci skip') }}