mirror of
https://github.com/jlengrand/detekt.git
synced 2026-03-10 08:11:23 +00:00
* Gradle 6.8.3 * Shadow 6.1.0 * Gradle Enterprise Gradle plugin 3.6 * Don't apply detekt plugin to detekt-bom module * Simplify detekt-generator custom tasks
107 lines
2.9 KiB
Kotlin
107 lines
2.9 KiB
Kotlin
import io.gitlab.arturbosch.detekt.Detekt
|
|
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
|
|
|
|
plugins {
|
|
kotlin("jvm") apply false
|
|
jacoco
|
|
packaging
|
|
releasing
|
|
detekt
|
|
id("com.github.ben-manes.versions")
|
|
id("org.sonarqube")
|
|
}
|
|
|
|
allprojects {
|
|
group = "io.gitlab.arturbosch.detekt"
|
|
version = Versions.currentOrSnapshot()
|
|
}
|
|
|
|
jacoco.toolVersion = Versions.JACOCO
|
|
|
|
tasks {
|
|
jacocoTestReport {
|
|
executionData.setFrom(fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec"))
|
|
|
|
val examplesOrTestUtils = setOf(
|
|
"detekt-bom",
|
|
"detekt-test",
|
|
"detekt-test-utils",
|
|
"detekt-sample-extensions"
|
|
)
|
|
|
|
subprojects
|
|
.filterNot { it.name in examplesOrTestUtils }
|
|
.forEach {
|
|
this@jacocoTestReport.sourceSets(it.sourceSets.main.get())
|
|
this@jacocoTestReport.dependsOn(it.tasks.test)
|
|
}
|
|
|
|
reports {
|
|
xml.isEnabled = true
|
|
xml.destination = file("$buildDir/reports/jacoco/report.xml")
|
|
}
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|