Skip to content

Commit

Permalink
Cleanup Gradle Plugin Pubblications
Browse files Browse the repository at this point in the history
  • Loading branch information
cortinico committed Apr 23, 2022
1 parent e249ba3 commit 446b2dd
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 29 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/pre-merge.yaml
Expand Up @@ -48,6 +48,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') }}
Expand Down
49 changes: 26 additions & 23 deletions build-logic/src/main/kotlin/packaging.gradle.kts
Expand Up @@ -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("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")
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions build.gradle.kts
Expand Up @@ -113,3 +113,33 @@ tasks.register("buildAll") {
}
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"))
}
3 changes: 0 additions & 3 deletions detekt-gradle-plugin/build.gradle.kts
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions scripts/release.sh
@@ -1,8 +1,8 @@
#!/usr/bin/env sh
gradle buildAll publishToMavenLocal -x detekt -x test || exit
gradle buildAll publishAllToMavenLocal -x detekt -x test || exit
gradle buildAll || 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

0 comments on commit 446b2dd

Please sign in to comment.