1- import kotlinx.kover.api.*
2- import kotlinx.kover.tasks.*
1+ import kotlinx.kover.gradle.plugin.dsl.*
32
43/*
54 * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
65 */
6+ plugins {
7+ id(" org.jetbrains.kotlinx.kover" )
8+ }
79
810val notCovered = sourceless + internal + unpublished
911
@@ -16,38 +18,60 @@ val expectedCoverage = mutableMapOf(
1618 " kotlinx-coroutines-reactor" to 75
1719)
1820
21+ val conventionProject = project
22+
1923subprojects {
2024 val projectName = name
2125 if (projectName in notCovered) return @subprojects
22- apply (plugin = " kover" )
2326
24- extensions.configure<KoverProjectConfig > {
27+ project.apply (plugin = " org.jetbrains.kotlinx.kover" )
28+ conventionProject.dependencies.add(" kover" , this )
29+
30+ extensions.configure<KoverProjectExtension >(" kover" ) {
2531 /*
26- * Is explicitly enabled on TC in a separate build step.
27- * Examples:
28- * ./gradlew :p:check -- doesn't verify coverage
29- * ./gradlew :p:check -Pkover.enabled=true -- verifies coverage
30- * ./gradlew :p:koverReport -Pkover.enabled=true -- generates report
31- */
32- isDisabled.set(! (properties[" kover.enabled" ]?.toString()?.toBoolean() ? : false ))
32+ * Is explicitly enabled on TC in a separate build step.
33+ * Examples:
34+ * ./gradlew :p:check -- doesn't verify coverage
35+ * ./gradlew :p:check -Pkover.enabled=true -- verifies coverage
36+ * ./gradlew :p:koverHtmlReport -Pkover.enabled=true -- generates HTML report
37+ */
38+ if (properties[" kover.enabled" ]?.toString()?.toBoolean() != true ) {
39+ disable()
40+ }
41+ }
3342
34- verify {
35- rule {
36- bound {
43+ extensions.configure<KoverReportExtension >(" koverReport" ) {
44+ defaults {
45+ html {
46+ setReportDir(conventionProject.layout.buildDirectory.dir(" kover/${project.name} /html" ))
47+ }
48+
49+ verify {
50+ rule {
3751 /*
38- * 85 is our baseline that we aim to raise to 90+.
39- * Missing coverage is typically due to bugs in the agent
40- * (e.g. signatures deprecated with an error are counted),
41- * sometimes it's various diagnostic `toString` or `catch` for OOMs/VerificationErrors,
42- * but some places are definitely worth visiting.
43- */
44- minValue = expectedCoverage[projectName] ? : 85 // COVERED_LINES_PERCENTAGE
52+ * 85 is our baseline that we aim to raise to 90+.
53+ * Missing coverage is typically due to bugs in the agent
54+ * (e.g. signatures deprecated with an error are counted),
55+ * sometimes it's various diagnostic `toString` or `catch` for OOMs/VerificationErrors,
56+ * but some places are definitely worth visiting.
57+ */
58+ minBound( expectedCoverage[projectName] ? : 85 ) // COVERED_LINES_PERCENTAGE
4559 }
4660 }
4761 }
62+ }
63+ }
4864
49- htmlReport {
50- reportDir.set(file(rootProject.buildDir.toString() + " /kover/" + project.name + " /html" ))
65+ koverReport {
66+ defaults {
67+ verify {
68+ rule {
69+ minBound(85 ) // COVERED_LINES_PERCENTAGE
70+ }
5171 }
5272 }
5373}
74+
75+ conventionProject.tasks.register(" koverReport" ) {
76+ dependsOn(conventionProject.tasks.named(" koverHtmlReport" ))
77+ }
0 commit comments