1
- import kotlinx.kover.api.*
2
- import kotlinx.kover.tasks.*
1
+ import kotlinx.kover.gradle.plugin.dsl.*
3
2
4
3
/*
5
4
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
6
5
*/
6
+ plugins {
7
+ id(" org.jetbrains.kotlinx.kover" )
8
+ }
7
9
8
10
val notCovered = sourceless + internal + unpublished
9
11
@@ -16,38 +18,60 @@ val expectedCoverage = mutableMapOf(
16
18
" kotlinx-coroutines-reactor" to 75
17
19
)
18
20
21
+ val conventionProject = project
22
+
19
23
subprojects {
20
24
val projectName = name
21
25
if (projectName in notCovered) return @subprojects
22
- apply (plugin = " kover" )
23
26
24
- extensions.configure<KoverProjectConfig > {
27
+ project.apply (plugin = " org.jetbrains.kotlinx.kover" )
28
+ conventionProject.dependencies.add(" kover" , this )
29
+
30
+ extensions.configure<KoverProjectExtension >(" kover" ) {
25
31
/*
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
+ }
33
42
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 {
37
51
/*
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
45
59
}
46
60
}
47
61
}
62
+ }
63
+ }
48
64
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
+ }
51
71
}
52
72
}
53
73
}
74
+
75
+ conventionProject.tasks.register(" koverReport" ) {
76
+ dependsOn(conventionProject.tasks.named(" koverHtmlReport" ))
77
+ }
0 commit comments