configure Sonar only on the root project, aggregate the sonar reports, and always generate Kover XML coverage reports after tests

This commit is contained in:
Adam 2023-06-05 22:20:06 +02:00
parent e45fc71ab9
commit 17ea49aba6
3 changed files with 20 additions and 14 deletions

View file

@ -22,3 +22,20 @@ plugins {
group = "net.thauvin.erik"
version = "1.4.0-SNAPSHOT"
dependencies {
kover(projects.lib)
kover(projects.app)
}
sonar {
properties {
property("sonar.projectName", rootProject.name)
property("sonar.projectKey", "ethauvin_${rootProject.name}")
property("sonar.organization", "ethauvin-github")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.sourceEncoding", "UTF-8")
property("sonar.coverage.jacoco.xmlReportPaths", "build/reports/kover/report.xml")
property("sonar.log.level", "DEBUG")
}
}

View file

@ -42,4 +42,6 @@ tasks.withType<Test>().configureEach {
exceptionFormat = TestExceptionFormat.FULL
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
}
finalizedBy(tasks.matching { it.name == "koverXmlReport" })
}

View file

@ -33,21 +33,8 @@ plugins {
id("org.jetbrains.kotlinx.kover")
}
sonar {
properties {
property("sonar.projectName", rootProject.name)
property("sonar.projectKey", "ethauvin_${rootProject.name}")
property("sonar.organization", "ethauvin-github")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.sourceEncoding", "UTF-8")
property("sonar.sources", files("src/main/kotlin"))
property("sonar.test", files("src/test/kotlin"))
property("sonar.coverage.jacoco.xmlReportPaths", "build/reports/kover/report.xml")
property("sonar.log.level", "DEBUG")
}
}
tasks.withType<SonarTask>().configureEach {
dependsOn(tasks.withType<Test>())
// workaround for https://github.com/Kotlin/kotlinx-kover/issues/394
dependsOn(tasks.matching { it.name == "koverXmlReport" })
}