Skip to content

Commit

Permalink
build: Add kover
Browse files Browse the repository at this point in the history
  • Loading branch information
DolphaGo committed Feb 12, 2025
1 parent b971f7b commit 9af902a
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package dev.dolphago

import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test

class BoardApiApplicationKtTest {

@Test
fun test() {
// given
val list = listOf(1, 2, 3)
.filter { it % 2 == 0 }

println(list.takeIf { it.isNotEmpty() } ?: "empty")
}
}

This file was deleted.

48 changes: 46 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.springframework.boot.gradle.tasks.bundling.BootJar

Expand All @@ -13,6 +12,7 @@ plugins {
id("io.spring.dependency-management") version Versions.springDependencyManagementVersion
id("org.sonarqube") version Versions.sonarqubeVersion
id("org.jlleitschuh.gradle.ktlint") version Versions.ktlintVersion
id("org.jetbrains.kotlinx.kover") version Versions.koverVersion
kotlin("plugin.spring") version Versions.kotlinVersion
kotlin("plugin.jpa") version Versions.kotlinVersion
kotlin("jvm") version Versions.kotlinVersion
Expand All @@ -31,6 +31,7 @@ allprojects {
plugin("org.springframework.boot")
plugin("io.spring.dependency-management")
plugin("org.sonarqube")
plugin("org.jetbrains.kotlinx.kover")
}

group = "dev.dolphago"
Expand Down Expand Up @@ -60,7 +61,6 @@ allprojects {

kotlin{
target {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = JvmTarget.JVM_21
Expand All @@ -85,4 +85,48 @@ allprojects {
testImplementation(Dependencies.TEST)
kapt("org.springframework.boot:spring-boot-configuration-processor")
}

koverReport {
defaults {
filters {
excludes {
classes("*.*Config*", "*.*Application*")
packages("*.configuration.*")
annotatedBy("*Generated*")
}
}

xml {
onCheck = true
filters {
excludes {
classes("*.*Config*", "*.*Application*")
packages("*.configuration.*")
annotatedBy("*Generated*")
}
}
}

verify {
onCheck = true
rule {
isEnabled = true
entity = kotlinx.kover.gradle.plugin.dsl.GroupingEntityType.APPLICATION
filters {
excludes {
classes("*.*Config*", "*.*Application*")
packages("*.configuration.*")
annotatedBy("*Generated*")
}
}

bound {
minValue = 0
metric = kotlinx.kover.gradle.plugin.dsl.MetricType.LINE
aggregation = kotlinx.kover.gradle.plugin.dsl.AggregationType.COVERED_PERCENTAGE
}
}
}
}
}
}
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ object Versions {
const val sonarqubeVersion = "5.0.0.4638"
const val ktlintVersion = "11.6.1"
const val springCloudAwsVersion = "3.0.0"
const val koverVersion = "0.7.6"
}
23 changes: 0 additions & 23 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
plugins {
id("org.jetbrains.kotlinx.kover.aggregation") version "0.9.0"
}

kover {
enableCoverage()
reports {
verify {
check(true)
rule {
filters {
excludesAnnotatedBy.add("*.Generated*")
excludedClasses.addAll("*.*Config*", "*.*Application*")
}

bound {
minValue = 0
}
}
}
}
}

rootProject.name = "board"

include("board-entity")
Expand Down

0 comments on commit 9af902a

Please sign in to comment.