build: apply instrumented test dependencies conditionally (#4698)

This commit is contained in:
James Rich 2026-03-03 10:29:26 -06:00 committed by GitHub
parent 8f055fda93
commit 17dcbed6b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 6 deletions

View file

@ -61,10 +61,13 @@ class AndroidRoomConventionPlugin : Plugin<Project> {
}
pluginManager.withPlugin("org.jetbrains.kotlin.android") {
val hasAndroidTest = projectDir.resolve("src/androidTest").exists()
dependencies {
"implementation"(roomRuntime)
"ksp"(roomCompiler)
"androidTestImplementation"(roomTesting)
if (hasAndroidTest) {
"androidTestImplementation"(roomTesting)
}
}
}
}

View file

@ -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()
}

View file

@ -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)