Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Kover plugin #1733

Merged
merged 4 commits into from Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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")
shanshin marked this conversation as resolved.
Show resolved Hide resolved
}

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
}
}
}