From a8755ca90cfd2775221fd3cae67334b95ddbd063 Mon Sep 17 00:00:00 2001 From: Thijs Koppen Date: Sun, 26 Nov 2023 20:18:15 +0100 Subject: [PATCH] Merge reports manually after tests --- build.gradle.kts | 33 +++++++++++++++++++++++++++------ examples/build.gradle.kts | 2 +- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9fe820b..c6355f0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,13 +16,8 @@ plugins { kotlin("jvm") - jacoco id("org.sonarqube") -} - -dependencies { - implementation(project(":library")) - implementation(project(":examples")) + jacoco } allprojects { @@ -49,8 +44,10 @@ configure(subprojects) { } tasks.jacocoTestReport { + dependsOn(tasks.test) finalizedBy(tasks.jacocoTestCoverageVerification) reports { + html.required = true xml.required = true } } @@ -64,6 +61,30 @@ configure(subprojects) { } } +val mergeReportsTaskName = "merged" +tasks.register(mergeReportsTaskName) { + dependsOn(project(":library").tasks.jacocoTestReport) + dependsOn(project(":examples").tasks.jacocoTestReport) + + executionData.setFrom( + fileTree(project.layout.projectDirectory) + .apply { include("**/jacoco/*.exec") } + ) + sourceSets( + project(":library").sourceSets["main"], + project(":examples").sourceSets["main"] + ) + + reports { + html.required = true + xml.required = true + } +} +tasks.test { + useJUnitPlatform() + finalizedBy(tasks[mergeReportsTaskName]) +} + project.afterEvaluate { getTasksByName("quarkusGenerateCode", true).forEach { task -> task.setDependsOn(task.dependsOn.filterIsInstance>() diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index 42d78de..727153c 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -36,5 +36,5 @@ ksp { } tasks.jacocoTestReport { - sourceSets(project(":library").sourceSets.getByName("main")) + sourceSets(project(":library").sourceSets["main"]) }