mirror of
https://github.com/jlengrand/detekt.git
synced 2026-03-10 08:11:23 +00:00
This will help reduce build times when changes are made to the precompiled script plugins used in the build. This is because a change in buildSrc causes the whole project to become out-of-date [0]. Using an included build instead works around this problem. [0] https://docs.gradle.org/7.2/userguide/organizing_gradle_projects.html#sec:build_sources
78 lines
2.1 KiB
Kotlin
78 lines
2.1 KiB
Kotlin
import io.gitlab.arturbosch.detekt.Detekt
|
|
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
|
|
|
|
plugins {
|
|
id("packaging")
|
|
id("releasing")
|
|
id("detekt")
|
|
alias(libs.plugins.gradleVersionz)
|
|
alias(libs.plugins.sonarqube)
|
|
}
|
|
|
|
allprojects {
|
|
group = "io.gitlab.arturbosch.detekt"
|
|
version = Versions.currentOrSnapshot()
|
|
}
|
|
|
|
val analysisDir = file(projectDir)
|
|
val baselineFile = file("$rootDir/config/detekt/baseline.xml")
|
|
val configFile = file("$rootDir/config/detekt/detekt.yml")
|
|
val statisticsConfigFile = file("$rootDir/config/detekt/statistics.yml")
|
|
|
|
val kotlinFiles = "**/*.kt"
|
|
val kotlinScriptFiles = "**/*.kts"
|
|
val resourceFiles = "**/resources/**"
|
|
val buildFiles = "**/build/**"
|
|
|
|
val detektFormat by tasks.registering(Detekt::class) {
|
|
description = "Formats whole project."
|
|
parallel = true
|
|
disableDefaultRuleSets = true
|
|
buildUponDefaultConfig = true
|
|
autoCorrect = true
|
|
setSource(analysisDir)
|
|
config.setFrom(listOf(statisticsConfigFile, configFile))
|
|
include(kotlinFiles)
|
|
include(kotlinScriptFiles)
|
|
exclude(resourceFiles)
|
|
exclude(buildFiles)
|
|
baseline.set(baselineFile)
|
|
reports {
|
|
xml.enabled = false
|
|
html.enabled = false
|
|
txt.enabled = false
|
|
}
|
|
}
|
|
|
|
val detektAll by tasks.registering(Detekt::class) {
|
|
description = "Runs the whole project at once."
|
|
parallel = true
|
|
buildUponDefaultConfig = true
|
|
setSource(analysisDir)
|
|
config.setFrom(listOf(statisticsConfigFile, configFile))
|
|
include(kotlinFiles)
|
|
include(kotlinScriptFiles)
|
|
exclude(resourceFiles)
|
|
exclude(buildFiles)
|
|
baseline.set(baselineFile)
|
|
reports {
|
|
xml.enabled = false
|
|
html.enabled = false
|
|
txt.enabled = false
|
|
}
|
|
}
|
|
|
|
val detektProjectBaseline by tasks.registering(DetektCreateBaselineTask::class) {
|
|
description = "Overrides current baseline."
|
|
buildUponDefaultConfig.set(true)
|
|
ignoreFailures.set(true)
|
|
parallel.set(true)
|
|
setSource(analysisDir)
|
|
config.setFrom(listOf(statisticsConfigFile, configFile))
|
|
include(kotlinFiles)
|
|
include(kotlinScriptFiles)
|
|
exclude(resourceFiles)
|
|
exclude(buildFiles)
|
|
baseline.set(baselineFile)
|
|
}
|