Skip to content

Commit

Permalink
Use Kover instead of JaCoCo for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Thijsiez committed Jan 6, 2024
1 parent 8b1d254 commit bc462f6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew test jacocoTestReport sonar --no-daemon --continue --info
run: ./gradlew koverXmlReport sonar --no-daemon --continue --info
33 changes: 18 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@

plugins {
kotlin("jvm")
id("org.jetbrains.kotlinx.kover")
id("org.sonarqube")
jacoco
}

dependencies {
kover(project(":examples"))
kover(project(":library"))
}

allprojects {
apply(plugin = "kotlin")
apply(plugin = "jacoco")
apply(plugin = "org.jetbrains.kotlinx.kover")

group = "ch.icken"
version = "0.1.0-SNAPSHOT"
Expand All @@ -46,12 +51,6 @@ configure(subprojects) {
tasks.test {
useJUnitPlatform()
}
tasks.jacocoTestReport {
reports {
html.required = true
xml.required = true
}
}

kotlin {
jvmToolchain(11)
Expand All @@ -62,6 +61,17 @@ tasks.test {
useJUnitPlatform()
}

koverReport {
filters {
includes {
packages(
"ch.icken.processor",
"ch.icken.query"
)
}
}
}

//Fixes issue with circular task dependency,
//see https://github.com/quarkusio/quarkus/issues/29698#issuecomment-1671861607
project.afterEvaluate {
Expand All @@ -74,10 +84,3 @@ project.afterEvaluate {
.filterNot { it.get().name == "processResources" })
}
}

sonar {
properties {
property("sonar.projectKey", "Thijsiez_panache-kotlin-dsl_AYsggGcmXmm3_FAoLWCF")
property("sonar.projectName", "panache-kotlin-dsl")
}
}
9 changes: 7 additions & 2 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ ksp {
arg("addGeneratedAnnotation", "true")
}

tasks.jacocoTestReport {
sourceSets(project(":library").sourceSets["main"])
tasks.compileKotlin {
dependsOn(tasks.compileQuarkusGeneratedSourcesJava)
}
tasks.configureEach {
if (name == "kspKotlin") {
dependsOn(tasks.compileQuarkusGeneratedSourcesJava)
}
}
8 changes: 7 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2023 Thijs Koppen
# Copyright 2023-2024 Thijs Koppen
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -26,7 +26,13 @@ kotlinPoetVersion=1.15.3
mockkVersion=1.13.8
#https://github.com/tschuchortdev/kotlin-compile-testing
compileTestingVersion=1.5.0
#https://github.com/Kotlin/kotlinx-kover
koverVersion=0.7.5
#https://github.com/SonarSource/sonar-scanner-gradle
sonarqubeVersion=4.4.1.3373

kotlin.code.style=official

sonar.projectKey=Thijsiez_panache-kotlin-dsl_AYsggGcmXmm3_FAoLWCF
sonar.projectName=panache-kotlin-dsl
sonar.coverage.jacoco.xmlReportPaths=**/build/reports/kover/report.xml
4 changes: 3 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Thijs Koppen
* Copyright 2023-2024 Thijs Koppen
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,7 @@ pluginManagement {
val quarkusVersion: String by settings
val kotlinVersion: String by settings
val kspVersion: String by settings
val koverVersion: String by settings
val sonarqubeVersion: String by settings

repositories {
Expand All @@ -31,6 +32,7 @@ pluginManagement {
kotlin("plugin.allopen") version kotlinVersion
kotlin("plugin.jpa") version kotlinVersion
id("com.google.devtools.ksp") version kspVersion
id("org.jetbrains.kotlinx.kover") version koverVersion
id("org.sonarqube") version sonarqubeVersion
}
}
Expand Down

0 comments on commit bc462f6

Please sign in to comment.