From 80c69e7cf7ff8631a8c54261f84051c810f72709 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 9 Jan 2024 11:04:28 +0100 Subject: [PATCH] Migrate "When running on the CI, run only debug test variants". Following notice here: https://github.com/Kotlin/kotlinx-kover/blob/v0.7.0/docs/gradle-plugin/migrations/migration-to-0.7.0.md#using-isdisabled-boolean-is-an-error-kover-test-task-config-was-removed --- app/build.gradle.kts | 21 +++++++++++++++++++++ build.gradle.kts | 24 ------------------------ 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c9c0603b3e..3b978b7935 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -20,6 +20,7 @@ import com.android.build.api.variant.FilterConfiguration.FilterType.ABI import extension.allFeaturesImpl import extension.allLibrariesImpl import extension.allServicesImpl +import org.jetbrains.kotlin.cli.common.toBooleanLenient plugins { id("io.element.android-compose-application") @@ -229,6 +230,26 @@ dependencies { } } +val ciBuildProperty = "ci-build" +val isCiBuild = if (project.hasProperty(ciBuildProperty)) { + val raw = project.property(ciBuildProperty) as? String + raw?.toBooleanLenient() == true || raw?.toIntOrNull() == 1 +} else { + false +} + +kover { + // When running on the CI, run only debug test variants + if (isCiBuild) { + excludeTests { + // Disable instrumentation for debug test tasks + tasks( + "testDebugUnitTest", + ) + } + } +} + // https://kotlin.github.io/kotlinx-kover/ // Run `./gradlew :app:koverHtmlReport` to get report at ./app/build/reports/kover // Run `./gradlew :app:koverXmlReport` to get XML report diff --git a/build.gradle.kts b/build.gradle.kts index 09e1f5880f..3031f0b4e7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,5 @@ import com.google.devtools.ksp.gradle.KspTask import org.apache.tools.ant.taskdefs.optional.ReplaceRegExp -import org.jetbrains.kotlin.cli.common.toBooleanLenient buildscript { dependencies { @@ -166,29 +165,6 @@ allprojects { apply(plugin = "org.jetbrains.kotlinx.kover") } -// When running on the CI, run only debug test variants -val ciBuildProperty = "ci-build" -val isCiBuild = if (project.hasProperty(ciBuildProperty)) { - val raw = project.property(ciBuildProperty) as? String - raw?.toBooleanLenient() == true || raw?.toIntOrNull() == 1 -} else { - false -} -if (isCiBuild) { - allprojects { - afterEvaluate { - tasks.withType().configureEach { - /* TODO - extensions.configure { - val enabled = name.contains("debug", ignoreCase = true) - disabledForProject.set(!enabled) - } - */ - } - } - } -} - // Register quality check tasks. tasks.register("runQualityChecks") { project.subprojects {