Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Gradle Plugin Publications #4752

Merged
merged 4 commits into from Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/pre-merge.yaml
Expand Up @@ -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') }}
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("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")
}
cortinico marked this conversation as resolved.
Show resolved Hide resolved
}
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-logic/src/main/kotlin/releasing.gradle.kts
Expand Up @@ -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"))
}
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
5 changes: 2 additions & 3 deletions 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