1 import kotlinx.kover.gradle.plugin.dsl.* 2 <lambda>null3plugins { 4 id("org.jetbrains.kotlinx.kover") 5 } 6 7 val notCovered = sourceless + unpublished 8 9 val expectedCoverage = mutableMapOf( 10 // These have lower coverage in general, it can be eventually fixed 11 "kotlinx-coroutines-swing" to 70, // awaitFrame is not tested 12 "kotlinx-coroutines-javafx" to 35, // JavaFx is not tested on TC because its graphic subsystem cannot be initialized in headless mode 13 14 // Reactor has lower coverage in general due to various fatal error handling features 15 "kotlinx-coroutines-reactor" to 75 16 ) 17 18 val conventionProject = project 19 <lambda>null20subprojects { 21 val projectName = name 22 if (projectName in notCovered) return@subprojects 23 24 project.apply(plugin = "org.jetbrains.kotlinx.kover") 25 conventionProject.dependencies.add("kover", this) 26 27 extensions.configure<KoverProjectExtension>("kover") { 28 /* 29 * Is explicitly enabled on TC in a separate build step. 30 * Examples: 31 * ./gradlew :p:check -- doesn't verify coverage 32 * ./gradlew :p:check -Pkover.enabled=true -- verifies coverage 33 * ./gradlew :p:koverHtmlReport -Pkover.enabled=true -- generates HTML report 34 */ 35 if (properties["kover.enabled"]?.toString()?.toBoolean() != true) { 36 disable() 37 } 38 } 39 40 extensions.configure<KoverProjectExtension>("kover") { 41 reports { 42 total { 43 html { 44 htmlDir = conventionProject.layout.buildDirectory.dir("kover/${project.name}/html") 45 } 46 47 verify { 48 rule { 49 /* 50 * 85 is our baseline that we aim to raise to 90+. 51 * Missing coverage is typically due to bugs in the agent 52 * (e.g. signatures deprecated with an error are counted), 53 * sometimes it's various diagnostic `toString` or `catch` for OOMs/VerificationErrors, 54 * but some places are definitely worth visiting. 55 */ 56 minBound(expectedCoverage[projectName] ?: 85) // COVERED_LINES_PERCENTAGE 57 } 58 } 59 } 60 } 61 } 62 } 63 <lambda>null64kover { 65 reports { 66 total { 67 verify { 68 rule { 69 minBound(85) // COVERED_LINES_PERCENTAGE 70 } 71 } 72 } 73 } 74 } 75 <lambda>null76conventionProject.tasks.register("koverReport") { 77 dependsOn(conventionProject.tasks.named("koverHtmlReport")) 78 } 79