https://kotlinlang.org logo
#detekt
Title
# detekt
e

Emanuel Moecklin

11/01/2023, 5:58 PM
I run Detekt in a multimodule project and while the
detekt {
configuration is applied to all sub projects (in the main build.gradle file)
Copy code
subprojects {
    apply plugin: "io.gitlab.arturbosch.detekt"
    detekt {
        debug = false
        parallel = true
        config.setFrom("${rootProject.projectDir}/default-detekt-config.yml")
        baseline = file("${rootProject.projectDir}/detekt-baseline.xml")
        buildUponDefaultConfig = true
        allRules = false
    }
}
the
task.detekt
configuration is ignored by sub projects:
Copy code
tasks.detekt.configure {
    exclude("**/test/**")
    reports {
        html.required.set(true)
How can I configure the Detekt task to be applied to all Gradle modules? The documentation has examples showing the task configuration included in the detekt closure/lambda but that seems to be deprecated (e.g. I get
HTML report location set on detekt {} extension will be ignored for detekt task.
)
b

Brais Gabin

11/01/2023, 6:04 PM
Can you open an issue regarding the outdated documentation? That should be fixed. Regarding the tasks snippet. Is it inside the
subprojects
lambda?
e

Emanuel Moecklin

11/01/2023, 6:19 PM
Regarding the tasks snippet. Is it inside the
subprojects
lambda?
no, if I add it to
subprojects
I get
Could not get unknown property 'detekt' for task set of type org.gradle.api.internal.tasks.DefaultTaskContainer.
I tried retrieving the task by name but that doesn't work either
hmm I tried different "flavors" or this and this actually seems to work
Copy code
tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach {
👍 1
12 Views