1 /*
<lambda>null2 * Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4 plugins {
5 id("org.jetbrains.kotlinx.kover")
6 }
7
<lambda>null8 kover {
9 if (hasProperty("kover.enabled") && property("kover.enabled") != "true") {
10 disable()
11 }
12
13 currentProject {
14 projectsForCoverageVerification.forEach { (variantName, _) ->
15 // copy the `main` variant for each module to check the coverage only in its section
16 copyVariant(variantName, "main")
17 }
18 }
19
20 merge {
21 // collect common coverage for all projects (except excluded) in `main` variant
22 subprojects { subproject ->
23 subproject.path !in uncoveredProjects
24 }
25 createVariant("main") { add("jvm", optional = true) }
26 }
27
28 reports {
29 total.verify.rule("Total coverage") {
30 minBound(90)
31 }
32
33 projectsForCoverageVerification.forEach { (variantName, projectPath) ->
34 variant(variantName) {
35 filters.includes.projects.add(projectPath)
36
37 // verify the coverage individually for each module by `check` task
38 verify {
39 onCheck = true
40 rule("Coverage for $projectPath") {
41 minBound(85)
42 }
43 }
44 }
45 }
46 }
47 }
48
49
50 val uncoveredProjects get() = setOf(":kotlinx-serialization-bom", ":benchmark", ":guide")
51 // map: variant name -> project path
52 val projectsForCoverageVerification get() = mapOf("core" to ":kotlinx-serialization-core", "json" to ":kotlinx-serialization-json", "jsonOkio" to ":kotlinx-serialization-json-okio", "cbor" to ":kotlinx-serialization-cbor", "hocon" to ":kotlinx-serialization-hocon", "properties" to ":kotlinx-serialization-properties", "protobuf" to ":kotlinx-serialization-protobuf", "io" to ":kotlinx-serialization-json-io")
53