From 2a11540bde9647f8428c67ecc6c0e83fcf809cc1 Mon Sep 17 00:00:00 2001 From: Yamil Medina Date: Mon, 8 Apr 2024 15:45:01 +0200 Subject: [PATCH] fix: test for multimodule (#2873) --- .../src/main/kotlin/AndroidLibraryConventionPlugin.kt | 8 ++++++++ .../src/main/kotlin/scripts/infrastructure.gradle.kts | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/build-logic/plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt b/build-logic/plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt index 10f33469603..a7af11e04cf 100644 --- a/build-logic/plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt +++ b/build-logic/plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt @@ -40,6 +40,14 @@ class AndroidLibraryConventionPlugin : Plugin { configureCompose(this) configureAndroidKotlinTests() + + buildTypes { + // submodules using this plugin can skip minification, since the app will do it + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } } } } diff --git a/buildSrc/src/main/kotlin/scripts/infrastructure.gradle.kts b/buildSrc/src/main/kotlin/scripts/infrastructure.gradle.kts index 002b525e69f..3c4ad9012b7 100644 --- a/buildSrc/src/main/kotlin/scripts/infrastructure.gradle.kts +++ b/buildSrc/src/main/kotlin/scripts/infrastructure.gradle.kts @@ -35,12 +35,15 @@ tasks.named("wrapper") { tasks.register("runUnitTests") { description = "Runs all Unit Tests." dependsOn(":app:test${Default.BUILD_VARIANT}UnitTest") + val buildType = + if (Default.BUILD_TYPE == Variants_gradle.BuildTypes.DEBUG) Default.BUILD_TYPE.capitalized() + else Variants_gradle.BuildTypes.RELEASE.capitalized() // valid submodules path to run unit tests val validSubprojects = setOf("core", "features") rootProject.subprojects { if (validSubprojects.contains(parent?.name)) { - dependsOn(":${parent?.name}:$name:test${Default.BUILD_TYPE.capitalized()}UnitTest") + dependsOn(":${parent?.name}:$name:test${buildType}UnitTest") } } }