Skip to content

Commit

Permalink
Move detekt-gradle-plugin to be a composite build
Browse files Browse the repository at this point in the history
  • Loading branch information
cortinico committed Apr 23, 2022
1 parent 2f0cc96 commit e249ba3
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributing to detekt

- Read [this article](https://chris.beams.io/posts/git-commit/) before writing commit messages.
- Use `gradle build -x dokkaJekyll` to build the source but exclude documentation JAR generation to save time.
- Use `gradle buildAll -x dokkaJekyll` to build the source but exclude documentation JAR generation to save time.
- Make sure that `gradle detekt` does not report any errors.
- This repository follows the [Kotlin coding conventions](https://kotlinlang.org/docs/reference/coding-conventions.html),
which are enforced by ktlint when running `gradle detekt`.
Expand All @@ -24,7 +24,7 @@ When implementing a new rule, do not forget to perform the following steps:
Kotlin projects with the `--run-rule RuleSet:RuleId` option to test your rule in isolation. Make use of
the `scripts/get_analysis_projects.kts` script to automatically establish a set of analysis projects.
- Run `./gradlew generateDocumentation` to add your rule and its config options to the `default-detekt-config.yml`.
- Run `./gradlew build`. This will execute tests locally.
- Run `./gradlew buildAll`. This will execute tests locally.

The following remarks might help you during the implementation:
- To print the AST of sources, you can pass the `--print-ast` flag to the CLI. This will print each
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Build detekt
uses: gradle/gradle-build-action@v2
with:
arguments: build
arguments: buildAll

- name: Deploy Snapshot
uses: gradle/gradle-build-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Build detekt
uses: gradle/gradle-build-action@v2
with:
arguments: build -x detekt
arguments: buildAll -x detekt
- uses: actions/upload-artifact@v3
with:
name: heap-dump
Expand Down
8 changes: 0 additions & 8 deletions build-logic/src/main/kotlin/releasing.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,4 @@ tasks {
linePartToFind.set("detekt_version:")
lineTransformation.set("detekt_version: ${Versions.DETEKT}")
}

register<UpdateVersionInFileTask>("applySelfAnalysisVersion") {
fileToUpdate.set(file("${rootProject.rootDir}/gradle/libs.versions.toml"))
linePartToFind.set("detekt = { id = \"io.gitlab.arturbosch.detekt\"")
lineTransformation.set(
"detekt = { id = \"io.gitlab.arturbosch.detekt\", version = \"${Versions.DETEKT}\" }"
)
}
}
10 changes: 9 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask

plugins {
id("releasing")
alias(libs.plugins.detekt)
id("io.gitlab.arturbosch.detekt")
alias(libs.plugins.gradleVersions)
alias(libs.plugins.sonarqube)
}
Expand Down Expand Up @@ -105,3 +105,11 @@ val detektProjectBaseline by tasks.registering(DetektCreateBaselineTask::class)
exclude(buildFiles)
baseline.set(baselineFile)
}

tasks.register("buildAll") {
description = "Build and test all the projects"
subprojects {
dependsOn(tasks.named("build"))
}
dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":build"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import org.junit.jupiter.api.Test
* When any breaking change in 'detekt-api' is done, this test will break.
*
* The procedure to repair this test is:
* 1. 'gradle build -x test publishToMavenLocal'
* 2. 'gradle build' again to let the 'sample' project pick up the new api changes.
* 1. 'gradle buildAll -x test publishToMavenLocal'
* 2. 'gradle buildAll' again to let the 'sample' project pick up the new api changes.
* 3. 'cp detekt-sample-extensions/build/libs/detekt-sample-extensions-<version>.jar
* detekt-core/src/test/resources/sample-rule-set.jar'
* 4. Now 'gradle build' should be green again.
Expand Down
7 changes: 3 additions & 4 deletions detekt-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ plugins {
alias(libs.plugins.pluginPublishing)
}

detekt {
source.from("src/functionalTest/kotlin")
}

repositories {
mavenCentral()
google()
}

group = "io.gitlab.arturbosch.detekt"
version = Versions.currentOrSnapshot()

testing {
suites {
getByName("test", JvmTestSuite::class) {
Expand Down
1 change: 0 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jcommander = "com.beust:jcommander:1.82"

[plugins]
binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.9.0" }
detekt = { id = "io.gitlab.arturbosch.detekt", version = "1.20.0" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
gradleVersions = { id = "com.github.ben-manes.versions", version = "0.42.0" }
pluginPublishing = { id = "com.gradle.plugin-publish", version = "0.21.0" }
Expand Down
6 changes: 3 additions & 3 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env sh
gradle build publishToMavenLocal -x detekt -x test || exit
gradle build || exit
gradle buildAll publishToMavenLocal -x detekt -x test || exit
gradle buildAll || exit
gradle publishAllPublicationsToMavenCentralRepository --max-workers 1 || exit
gradle publishPlugins -DautomatePublishing=true || exit
gradle githubRelease || exit
gradle applyDocVersion applySelfAnalysisVersion || exit
gradle applyDocVersion || exit
gradle closeAndReleaseRepository || exit
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ rootProject.name = "detekt"

pluginManagement {
includeBuild("build-logic")
includeBuild("detekt-gradle-plugin")
}

include("code-coverage-report")
Expand All @@ -12,7 +13,6 @@ include("detekt-cli")
include("detekt-core")
include("detekt-formatting")
include("detekt-generator")
include("detekt-gradle-plugin")
include("detekt-metrics")
include("detekt-parser")
include("detekt-psi-utils")
Expand Down

0 comments on commit e249ba3

Please sign in to comment.