From 09a10678de532e8a499cbdf9d4f97ab0fd6fdd1a Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Tue, 7 Dec 2021 14:48:08 +0530 Subject: build: add kotlinx-kover for library code coverage --- build-logic/kotlin-plugins/build.gradle.kts | 1 + .../com.github.android-password-store.kotlin-library.gradle.kts | 9 ++++++++- dependency-sync/build.gradle.kts | 1 + gradle/libs.versions.toml | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/build-logic/kotlin-plugins/build.gradle.kts b/build-logic/kotlin-plugins/build.gradle.kts index 0ce8e9de..d1c9a3af 100644 --- a/build-logic/kotlin-plugins/build.gradle.kts +++ b/build-logic/kotlin-plugins/build.gradle.kts @@ -11,6 +11,7 @@ plugins { dependencies { implementation(libs.build.agp) implementation(libs.build.binarycompat) + implementation(libs.build.kover) implementation(libs.build.kotlin) implementation(libs.build.spotless) } diff --git a/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-library.gradle.kts b/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-library.gradle.kts index 516f5e4f..d8e88bf5 100644 --- a/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-library.gradle.kts +++ b/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-library.gradle.kts @@ -6,7 +6,10 @@ import org.gradle.kotlin.dsl.withType import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -plugins { id("com.github.android-password-store.kotlin-common") } +plugins { + id("com.github.android-password-store.kotlin-common") + id("org.jetbrains.kotlinx.kover") +} tasks.withType().configureEach { kotlinOptions { @@ -15,3 +18,7 @@ tasks.withType().configureEach { } } } + +tasks.koverCollectReports { + outputDir.set(rootProject.layout.buildDirectory.dir("coverage-reports")) +} diff --git a/dependency-sync/build.gradle.kts b/dependency-sync/build.gradle.kts index a4fafc69..d5d0307b 100644 --- a/dependency-sync/build.gradle.kts +++ b/dependency-sync/build.gradle.kts @@ -15,6 +15,7 @@ dependencies { dependencySync("com.squareup.okhttp3:okhttp:4.9.3") dependencySync("com.vdurmont:semver4j:3.1.0") dependencySync("com.diffplug.spotless:spotless-plugin-gradle:6.0.4") + dependencySync("org.jetbrains.kotlinx:kover:0.4.4") // Kotlin dependencies dependencySync("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0-RC") diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 07577224..347bf55e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -62,6 +62,7 @@ testing-sharedPrefsMock = "com.github.android-password-store:shared-preferences- build-agp = "com.android.tools.build:gradle:7.0.3" build-binarycompat = "org.jetbrains.kotlinx:binary-compatibility-validator:0.8.0" +build-kover = "org.jetbrains.kotlinx:kover:0.4.4" kotlin-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" } kotlin-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } kotlin-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } -- cgit v1.2.3