Skip to content

Commit 8124ce4

Browse files
shanshinqwwdfsad
andauthored
Upgraded Kover version to 0.7.0-Beta (#3734)
Co-authored-by: Vsevolod Tolstopyatov <[email protected]>
1 parent 2e92d58 commit 8124ce4

File tree

9 files changed

+107
-62
lines changed

9 files changed

+107
-62
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ buildscript {
6666
classpath "com.github.node-gradle:gradle-node-plugin:$gradle_node_version"
6767
classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$binary_compatibility_validator_version"
6868
classpath "ru.vyarus:gradle-animalsniffer-plugin:1.5.4" // Android API check
69-
classpath "org.jetbrains.kotlinx:kover:$kover_version"
7069
classpath "org.jetbrains.kotlin:atomicfu:$kotlin_version"
70+
classpath "org.jetbrains.kotlinx:kover-gradle-plugin:$kover_version"
7171

7272
// JMH plugins
7373
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"

buildSrc/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ dependencies {
6262
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
6363
}
6464
implementation("ru.vyarus:gradle-animalsniffer-plugin:1.5.3") // Android API check
65-
implementation("org.jetbrains.kotlinx:kover:${version("kover")}") {
65+
implementation("org.jetbrains.kotlinx:kover-gradle-plugin:${version("kover")}") {
6666
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
6767
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7")
6868
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
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

810
val 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+
1923
subprojects {
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+
}

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ rxjava3_version=3.0.2
2323
javafx_version=17.0.2
2424
javafx_plugin_version=0.0.8
2525
binary_compatibility_validator_version=0.12.0
26-
kover_version=0.6.1
26+
kover_version=0.7.0-Beta
2727
blockhound_version=1.0.2.RELEASE
2828
jna_version=5.9.0
2929

kotlinx-coroutines-core/build.gradle

+22-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
apply plugin: 'org.jetbrains.kotlin.multiplatform'
66
apply plugin: 'org.jetbrains.dokka'
7+
8+
// apply plugin to use autocomplete for Kover DSL
9+
apply plugin: 'org.jetbrains.kotlinx.kover'
10+
711
apply from: rootProject.file("gradle/compile-jvm-multiplatform.gradle")
812
apply from: rootProject.file("gradle/compile-common.gradle")
913

@@ -320,12 +324,26 @@ def commonKoverExcludes =
320324
]
321325

322326
kover {
323-
instrumentation {
324-
excludeTasks.add("jvmLincheckTest") // Always disabled, lincheck doesn't really support coverage
327+
excludeTests {
328+
// Always disabled, lincheck doesn't really support coverage
329+
tasks("jvmLincheckTest")
330+
}
331+
332+
excludeInstrumentation {
333+
// lincheck has NPE error on `ManagedStrategyStateHolder` class
334+
classes("org.jetbrains.kotlinx.lincheck.*")
325335
}
336+
}
337+
338+
koverReport {
326339
filters {
327-
classes {
328-
excludes.addAll(commonKoverExcludes)
340+
excludes {
341+
classes(
342+
"kotlinx.coroutines.debug.*", // Tested by debug module
343+
"kotlinx.coroutines.channels.ChannelsKt__DeprecatedKt.*", // Deprecated
344+
"kotlinx.coroutines.scheduling.LimitingDispatcher", // Deprecated
345+
"kotlinx.coroutines.scheduling.ExperimentalCoroutineDispatcher" // Deprecated
346+
)
329347
}
330348
}
331349
}

kotlinx-coroutines-debug/build.gradle

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
apply plugin: "com.github.johnrengelman.shadow"
66

7+
// apply plugin to use autocomplete for Kover DSL
8+
apply plugin: 'org.jetbrains.kotlinx.kover'
9+
710
configurations {
811
shadowDeps // shaded dependencies, not included into the resulting .pom file
912
compileOnly.extendsFrom(shadowDeps)
@@ -53,14 +56,11 @@ configurations {
5356
}
5457
}
5558

56-
def commonKoverExcludes =
57-
// Never used, safety mechanism
58-
["kotlinx.coroutines.debug.internal.NoOpProbesKt"]
59-
60-
tasks.koverHtmlReport {
61-
excludes = commonKoverExcludes
62-
}
63-
64-
tasks.koverVerify {
65-
excludes = commonKoverExcludes
59+
koverReport {
60+
filters {
61+
excludes {
62+
// Never used, safety mechanism
63+
classes("kotlinx.coroutines.debug.internal.NoOpProbesKt")
64+
}
65+
}
6666
}

reactive/kotlinx-coroutines-reactive/build.gradle.kts

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
import kotlinx.kover.gradle.plugin.dsl.*
2+
13
/*
24
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
35
*/
46

7+
plugins {
8+
// apply plugin to use autocomplete for Kover DSL
9+
id("org.jetbrains.kotlinx.kover")
10+
}
11+
512
val reactiveStreamsVersion = property("reactive_streams_version")
613

714
dependencies {
@@ -35,16 +42,14 @@ externalDocumentationLink(
3542
url = "https://www.reactive-streams.org/reactive-streams-$reactiveStreamsVersion-javadoc/"
3643
)
3744

38-
val commonKoverExcludes = listOf(
39-
"kotlinx.coroutines.reactive.FlowKt", // Deprecated
40-
"kotlinx.coroutines.reactive.FlowKt__MigrationKt", // Deprecated
41-
"kotlinx.coroutines.reactive.ConvertKt" // Deprecated
42-
)
43-
44-
kover {
45+
koverReport {
4546
filters {
46-
classes {
47-
excludes += commonKoverExcludes
47+
excludes {
48+
classes(
49+
"kotlinx.coroutines.reactive.FlowKt", // Deprecated
50+
"kotlinx.coroutines.reactive.FlowKt__MigrationKt", // Deprecated
51+
"kotlinx.coroutines.reactive.ConvertKt" // Deprecated
52+
)
4853
}
4954
}
5055
}

reactive/kotlinx-coroutines-reactor/build.gradle.kts

+11-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
plugins {
6+
// apply plugin to use autocomplete for Kover DSL
7+
id("org.jetbrains.kotlinx.kover")
8+
}
9+
510
val reactorVersion = version("reactor")
611

712
dependencies {
@@ -28,15 +33,14 @@ externalDocumentationLink(
2833
url = "https://projectreactor.io/docs/core/$reactorVersion/api/"
2934
)
3035

31-
val commonKoverExcludes = listOf(
32-
"kotlinx.coroutines.reactor.FlowKt", // Deprecated
33-
"kotlinx.coroutines.reactor.ConvertKt\$asFlux$1" // Deprecated
34-
)
3536

36-
kover {
37+
koverReport {
3738
filters {
38-
classes {
39-
excludes += commonKoverExcludes
39+
excludes {
40+
classes(
41+
"kotlinx.coroutines.reactor.FlowKt", // Deprecated
42+
"kotlinx.coroutines.reactor.ConvertKt\$asFlux$1" // Deprecated
43+
)
4044
}
4145
}
4246
}

ui/kotlinx-coroutines-android/build.gradle.kts

-6
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,3 @@ open class RunR8 : JavaExec() {
112112
super.exec()
113113
}
114114
}
115-
116-
tasks.withType<Test> {
117-
extensions.configure<KoverTaskExtension> {
118-
excludes.addAll(listOf("com.android.*", "android.*")) // Exclude robolectric-generated classes
119-
}
120-
}

0 commit comments

Comments
 (0)