From d91315f057e7dac4a860ccc1af3334080e59390e Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Tue, 3 Mar 2026 10:28:49 -0600 Subject: [PATCH] build: apply instrumented test dependencies conditionally Check for the existence of `src/androidTest` before adding test-related dependencies in convention plugins. This prevents unnecessary dependency resolution for modules without instrumented tests. Additionally, removed unused test dependencies from the firmware feature module. Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com> --- .../src/main/kotlin/AndroidRoomConventionPlugin.kt | 5 ++++- .../kotlin/org/meshtastic/buildlogic/AndroidCompose.kt | 9 +++++++-- feature/firmware/build.gradle.kts | 3 --- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/build-logic/convention/src/main/kotlin/AndroidRoomConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidRoomConventionPlugin.kt index eeecb90773..b4603b2f36 100644 --- a/build-logic/convention/src/main/kotlin/AndroidRoomConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidRoomConventionPlugin.kt @@ -61,10 +61,13 @@ class AndroidRoomConventionPlugin : Plugin { } pluginManager.withPlugin("org.jetbrains.kotlin.android") { + val hasAndroidTest = projectDir.resolve("src/androidTest").exists() dependencies { "implementation"(roomRuntime) "ksp"(roomCompiler) - "androidTestImplementation"(roomTesting) + if (hasAndroidTest) { + "androidTestImplementation"(roomTesting) + } } } } diff --git a/build-logic/convention/src/main/kotlin/org/meshtastic/buildlogic/AndroidCompose.kt b/build-logic/convention/src/main/kotlin/org/meshtastic/buildlogic/AndroidCompose.kt index 20944be9b2..a23ca91ab4 100644 --- a/build-logic/convention/src/main/kotlin/org/meshtastic/buildlogic/AndroidCompose.kt +++ b/build-logic/convention/src/main/kotlin/org/meshtastic/buildlogic/AndroidCompose.kt @@ -31,10 +31,13 @@ internal fun Project.configureAndroidCompose( buildFeatures.compose = true } + val hasAndroidTest = project.projectDir.resolve("src/androidTest").exists() dependencies { val bom = libs.library("androidx-compose-bom") "implementation"(platform(bom)) - "androidTestImplementation"(platform(bom)) + if (hasAndroidTest) { + "androidTestImplementation"(platform(bom)) + } "implementation"(libs.library("androidx-compose-ui-tooling")) "implementation"(libs.library("androidx-compose-runtime")) "runtimeOnly"(libs.library("androidx-compose-runtime-tracing")) @@ -44,7 +47,9 @@ internal fun Project.configureAndroidCompose( "implementation"(libs.library("compose-multiplatform-resources")) // Add Espresso explicitly to avoid version mismatch issues on newer Android versions - "androidTestImplementation"(libs.library("androidx-test-espresso-core")) + if (hasAndroidTest) { + "androidTestImplementation"(libs.library("androidx-test-espresso-core")) + } } configureComposeCompiler() } diff --git a/feature/firmware/build.gradle.kts b/feature/firmware/build.gradle.kts index 265d4334c2..9305aa57ba 100644 --- a/feature/firmware/build.gradle.kts +++ b/feature/firmware/build.gradle.kts @@ -58,9 +58,6 @@ dependencies { implementation(libs.markdown.renderer) implementation(libs.markdown.renderer.m3) - androidTestImplementation(libs.androidx.compose.ui.test.junit4) - androidTestImplementation(libs.androidx.test.ext.junit) - testImplementation(libs.junit) testImplementation(libs.kotlinx.coroutines.test) testImplementation(libs.nordic.client.android.mock)