Skip to content

Commit

Permalink
Add Kover plugin (#1733)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergey.Shanshin <sergey.shanshin@jetbrains.com>
  • Loading branch information
sandwwraith and shanshin committed Oct 29, 2021
1 parent c06ebb4 commit e721ebe
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 6 deletions.
9 changes: 8 additions & 1 deletion build.gradle
Expand Up @@ -23,6 +23,7 @@ buildscript {
"-Xopt-in=kotlinx.serialization.InternalSerializationApi",
"-Xopt-in=kotlin.ExperimentalUnsignedTypes"
]
ext.koverEnabled = property('kover.enabled') ?: true

/*
* This property group is used to build kotlinx.serialization against Kotlin compiler snapshot.
Expand Down Expand Up @@ -64,6 +65,7 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
classpath "org.jetbrains.kotlinx:kover:$kover_version"
classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$validator_version"
classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version"
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.5.3' // Android API check
Expand Down Expand Up @@ -158,7 +160,9 @@ subprojects {

subprojects {
// Can't be applied to BOM
if (project.name == "kotlinx-serialization-bom" || project.name == "benchmark") return
if (project.name == "kotlinx-serialization-bom" || project.name == "benchmark" || project.name == "guide") return

// Animalsniffer setup
apply plugin: 'ru.vyarus.animalsniffer'

afterEvaluate { // Can be applied only when the project is evaluated
Expand All @@ -170,6 +174,9 @@ subprojects {
signature 'org.codehaus.mojo.signature:java18:1.0@signature'
}
}

// Kover setup
apply from: rootProject.file("gradle/kover.gradle")
}

apply from: rootProject.file('gradle/compiler-version.gradle')
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply plugin: 'kotlin-multiplatform'
Expand Down
2 changes: 1 addition & 1 deletion formats/cbor/build.gradle
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply plugin: 'kotlin-multiplatform'
Expand Down
2 changes: 1 addition & 1 deletion formats/json/build.gradle
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply plugin: 'kotlin-multiplatform'
Expand Down
2 changes: 1 addition & 1 deletion formats/properties/build.gradle
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply plugin: 'kotlin-multiplatform'
Expand Down
2 changes: 1 addition & 1 deletion formats/protobuf/build.gradle
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply plugin: 'java' // Needed for protobuf plugin only
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Expand Up @@ -18,6 +18,9 @@ native.deploy=
validator_version=0.7.1
knit_version=0.2.2
coroutines_version=1.3.9
kover_version=0.3.0

kover.enabled=true

kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.mpp.enableCompatibilityMetadataVariant=true
Expand Down
21 changes: 21 additions & 0 deletions gradle/kover.gradle
@@ -0,0 +1,21 @@
/*
* Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply plugin: 'kover'

tasks.withType(Test) { task ->
// Core is mainly uncovered because a lot of serializers are tested with JSON
def minPercentage = (project.name.contains("core") || project.name.contains("properties")) ? 50 : 80
kover {
enabled = rootProject.ext.koverEnabled
generateXml = false
generateHtml = true
htmlReportDir.set(file("${rootProject.buildDir}/kover/${project.name}/html"))
verificationRule {
name = "Minimal line coverage rate in percents"
minValue = minPercentage
// valueType is 'COVERED_LINES_PERCENTAGE' by default
}
}
}

0 comments on commit e721ebe

Please sign in to comment.