Cleanup Gradle Plugin Publications (#4752)

This commit is contained in:
Nicola Corti
2022-04-26 12:20:00 +01:00
committed by GitHub
parent cc2f9a615d
commit dac5401949
5 changed files with 62 additions and 29 deletions

View File

@@ -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') }}

View File

@@ -27,31 +27,34 @@ publishing {
}
}
}
publications.register<MavenPublication>(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<MavenPublication>(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")
}
}
}

View File

@@ -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"))
}

View File

@@ -73,9 +73,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"

View File

@@ -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