mirror of
https://github.com/jlengrand/detekt.git
synced 2026-03-10 08:11:23 +00:00
* Update Kotlin to 1.5 * Add workaround for Kotlin 1.5 memory leak in Gradle * API changes * Don't treat warnings as errors on the detekt-gradle-plugin module
110 lines
3.0 KiB
Kotlin
110 lines
3.0 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")
|
|
|
|
// remove once Kotlin 1.5.10 is released (https://youtrack.jetbrains.com/issue/KT-46368)
|
|
id("dev.zacsweers.kgp-150-leak-patcher") version "1.1.0"
|
|
}
|
|
|
|
allprojects {
|
|
group = "io.gitlab.arturbosch.detekt"
|
|
version = Versions.currentOrSnapshot()
|
|
}
|
|
|
|
jacoco.toolVersion = libs.versions.jacoco.get()
|
|
|
|
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)
|
|
}
|