Skip to content

Instantly share code, notes, and snippets.

@bobbyirawan09
Created January 20, 2022 07:33
Show Gist options
  • Save bobbyirawan09/bf6968d54c560719ae8b6a5a285e0da2 to your computer and use it in GitHub Desktop.
Save bobbyirawan09/bf6968d54c560719ae8b6a5a285e0da2 to your computer and use it in GitHub Desktop.
Step 2 when adding Detekt to project, add the configuration
allprojects {
apply(plugin = "io.gitlab.arturbosch.detekt") // Version should be inherited from parent
repositories {
google()
mavenCentral()
}
/**
* Step 2
*
* Source https://github.com/JLLeitschuh/ktlint-gradle/blob/master/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/KtlintExtension.kt
* Source from https://detekt.github.io/detekt/gradle.html#kotlin-dsl-3
* */
detekt {
source = files("src/main/java", "src/main/kotlin")
toolVersion = "1.18.1"
debug = true
config = files("${project.rootDir}/reports/detekt/config.yml")
baseline = file("${project.rootDir}/reports/detekt/baseline.xml")
ignoredBuildTypes = listOf("release")
basePath = "${project.rootDir}/reports/detekt"
reports {
html {
enabled = true
destination = file("${project.rootDir}/reports/detekt/detekt.html")
}
txt {
enabled = true
destination = file("${project.rootDir}/reports/detekt/detekt.txt")
}
}
}
plugins.withType(io.gitlab.arturbosch.detekt.DetektPlugin::class) {
tasks.withType(io.gitlab.arturbosch.detekt.Detekt::class) detekt@{
finalizedBy(reportMerge)
reportMerge.configure {
input.from(this@detekt.xmlReportFile)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment