Hello! I am giving version 2.0.0-alpha.0 a try, an...
# detekt
e
Hello! I am giving version 2.0.0-alpha.0 a try, and I ran into a problem caused by what I believe to be how I use
ReportMergeTask
. In v1, it looks like the Detekt tasks were created only for the variants that were not being filtered out. But now in v2 they are created for all the variants, but only the ones that are not filtered out are linked to the main task as a dependency. However, that means that the merge task, when configured similar to these docs, it will trigger all the registered tasks, although some of them should ignored. I will post my configuration in the thread below, for more clarity. But the question is: am I supposed to do something differently now?
Here's the contents of my convention plugin:
Copy code
private val reportMerge by
    tasks.registering(dev.detekt.gradle.report.ReportMergeTask::class) {
        output.set(
            rootProject.layout.buildDirectory.file(
                "reports/detekt/merge.xml"
            )
        )
    }

detekt {
    basePath.set(projectDir)
    parallel = true
    config.from(files("${rootProject.layout.projectDirectory.dir("detekt")}/detekt-config.yml"))
    ignoredBuildTypes = listOf("release", "official")
    ignoredFlavors = listOf("production")
    autoCorrect = false
}

tasks.withType<dev.detekt.gradle.Detekt>().configureEach {
    finalizedBy(reportMerge)
}


reportMerge {
    input.from(
        tasks.withType<dev.detekt.gradle.Detekt>().map {
            it.reports.xml.outputLocation
        }
    )
}
Running
./gradlew sendmoney:detektMain
I can see:
Copy code
> Task :sendmoney:detektDebug
> Task :sendmoney:detektRelease
Ah, actually, if I remove the
finalizedBy(reportMerge)
from the task configuration, it seems to work correctly 😅 Not sure why I had it in the first place.
Ok, it seems like the reason why I added that is that the reports are merged after running
./gradlew detektMain detektTest --continue
. Now if instead I just execute
reportMerge
, the non-type resolution enabled detekt tasks get executed instead. Am I holding it wrong?