Hi
I’m working on multimodule Android project and use Gradle Kotlin DSL in it. I want to integrate Jacoco test coverage reporting into it. Since I don’t want to duplicate the plugin integration and configuration in every module I did the following:
-
Created custom precompiled script plugin testCoverage.gradle.kts and put it into my buildSrc. Contents are the following:
plugins { jacoco } afterEvaluate { configure<JacocoPluginExtension> { toolVersion = jacoco_version } tasks.withType<Test> { configure<JacocoTaskExtension> { isIncludeNoLocationClasses = true } } tasks.withType<JacocoReport> { reports { xml.isEnabled = false csv.isEnabled = false html.isEnabled = true } } }
-
In myProject build.gradle.kts I added the following lines:
plugins { id("testCoverage") apply false } subprojects { apply(plugin="testCoverage") }
When I run myProject:jacocTestReportDebug then reports are generated for the modules, but each module generates report in csv and xml formats even though I configured the tasks to only generate html output.
If I remove configuration from the myProject’s build.gradle.kts and add plugin directly into module’s build.gradle.kts and run the same task then only html report will be generated, just as expected.
What do I need to change to be able to make Jacoco generate only html report and at the same time keep configuratio for all modules in the subprojects block of the top level project?