diff --git a/.github/workflows/pre-merge.yaml b/.github/workflows/pre-merge.yaml index d4405ed279e..f581cf54aea 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 to Maven Local + uses: gradle/gradle-build-action@v2 + with: + arguments: publishToMavenLocal 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..cef85110f42 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("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") + developers { + developer { + id.set("Detekt Developers") + name.set("Detekt Developers") + email.set("info@detekt.dev") + } + } + scm { + url.set("https://github.com/detekt/detekt") } - } - scm { - url.set("https://github.com/detekt/detekt") } } } diff --git a/build-logic/src/main/kotlin/releasing.gradle.kts b/build-logic/src/main/kotlin/releasing.gradle.kts index 0a38fb6e322..0c9aec26605 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")) +} 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