Skip to content

Commit

Permalink
Replace deprecated JacocoMerge task (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp94831 authored Feb 22, 2024
1 parent 0008190 commit a1474ce
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions sonar/src/main/kotlin/com/bakdata/gradle/SonarPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,26 @@ class SonarPlugin : Plugin<Project> {
}

if (!subprojects.isEmpty()) {
val jacocoMerge by tasks.registering(JacocoMerge::class) {
tasks.register<JacocoReport>("jacocoRootReport") {
subprojects {
executionData(tasks.withType<JacocoReport>().map { it.executionData })
}
destinationFile = file("$buildDir/jacoco")
}
tasks.register<JacocoReport>("jacocoRootReport") {
dependsOn(jacocoMerge)
sourceDirectories.from(files(subprojects.map {
it.the<SourceSetContainer>()["main"].allSource.srcDirs
}))
classDirectories.from(files(subprojects.map { it.the<SourceSetContainer>()["main"].output }))
executionData(jacocoMerge.get().destinationFile)
reports {
html.isEnabled = true
xml.isEnabled = true
csv.isEnabled = false
html.required.set(true)
xml.required.set(true)
csv.required.set(false)
}
}

// using a newer feature of sonarqube to use the xml reports which also makes it language-agnostic
configure<org.sonarqube.gradle.SonarExtension> {
properties {
property("sonar.coverage.jacoco.xmlReportPaths",
rootProject.tasks.withType<JacocoReport>().map { it.reports.xml.destination })
rootProject.tasks.withType<JacocoReport>().map { it.reports.xml.outputLocation.asFile })
}
}
}
Expand Down

0 comments on commit a1474ce

Please sign in to comment.