From 527ae2230f5c2dd22f496f45d5d8e3bd4acdb854 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Mon, 4 Apr 2022 16:10:32 +0200 Subject: ci: Fix JaCoCo report aggregation This change updates the build script to fix the aggregation step for the JaCoCo coverage reports that are submitted to Codecov. Previously, not all modules were properly included in the report. --- .../src/main/kotlin/jacoco-aggregation.gradle.kts | 34 ++++++++++------------ 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'buildSrc/src/main') diff --git a/buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts b/buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts index 5afd3e0d..7ae42cd2 100644 --- a/buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts +++ b/buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts @@ -22,7 +22,8 @@ plugins { - jacoco + base + id("jacoco-report-aggregation") } repositories { @@ -30,25 +31,20 @@ repositories { mavenCentral() } -tasks.register("codeCoverageReport") { - group = "Coverage reports" - description = "Generates an aggregate report based on all subprojects" - - reports { - xml.required.set(true) - xml.outputLocation.set(file("${buildDir}/reports/jacoco/report.xml")) - - html.required.set(true) - } - +dependencies { subprojects { - this@subprojects.plugins.withType().configureEach { - this@subprojects.tasks.matching { - it.extensions.findByType() != null } - .configureEach { - sourceSets(this@subprojects.the().named("main").get()) - executionData(this) - } + plugins.withType().configureEach { + jacocoAggregation(this@subprojects) } + } } + +@Suppress("UnstableApiUsage") +val codeCoverageReport by reporting.reports.creating(JacocoCoverageReport::class) { + testType.set(TestSuiteType.UNIT_TEST) +} + +tasks.check { + dependsOn(codeCoverageReport.reportTask) +} -- cgit v1.2.3