https://kotlinlang.org logo
Title
d

Dariusz Kuc

11/26/2019, 8:00 PM
hello! by any chance anyone here got a working example of custom jacoco task (in kts) that aggregates all individual module results into single report? All the examples I found are for Groovy and I'm having trouble rewriting it in Kotlin
if anyone is searching for the same this is what worked for me
tasks.register(name = "jacocoRootReport", type = JacocoReport::class) {
    description = "Generates an aggregate Jacoco report from all subprojects"
    group = "Verification"

    subprojects.forEach { subProject ->
        subProject.tasks.findByName("test")?.let { testTask ->
            dependsOn(testTask)
        }
        executionData.setFrom(file("${subProject.buildDir}/jacoco/test.exec"))
        classDirectories.from(file("${subProject.buildDir}/classes/kotlin/main"))
    }
}