From 930e061611d02192afe6dbae1bae7b2358e75607 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Thu, 21 Mar 2024 19:55:11 +0100 Subject: [PATCH] Cleanup dependencies This is a followup cleanup of #1163 that was partially addressed by #1140. - Remove unused `projects.core.testing` dependencies (or replace with direct dependencies). - Introduce `androidx.compose.ui.test` bundle. - Remove `NiaTestRunner` from the default config, forcing consumers to depend on it, even when not used. --- app/build.gradle.kts | 3 ++- .../src/main/kotlin/AndroidFeatureConventionPlugin.kt | 4 ---- .../src/main/kotlin/AndroidLibraryConventionPlugin.kt | 2 ++ core/database/build.gradle.kts | 8 +++----- core/designsystem/build.gradle.kts | 5 +---- core/screenshot-testing/build.gradle.kts | 7 +++---- core/testing/build.gradle.kts | 9 ++------- core/ui/build.gradle.kts | 4 +--- feature/bookmarks/build.gradle.kts | 1 + feature/foryou/build.gradle.kts | 4 ++-- feature/interests/build.gradle.kts | 1 + feature/search/build.gradle.kts | 1 + feature/settings/build.gradle.kts | 2 +- feature/topic/build.gradle.kts | 1 + gradle/libs.versions.toml | 3 +++ 15 files changed, 24 insertions(+), 31 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9e68ffa7d..1eb28cd46 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -112,7 +112,6 @@ dependencies { kspTest(libs.hilt.compiler) testImplementation(projects.core.dataTest) - testImplementation(projects.core.testing) testImplementation(libs.accompanist.testharness) testImplementation(libs.hilt.android.testing) testImplementation(libs.work.testing) @@ -121,12 +120,14 @@ dependencies { testDemoImplementation(libs.roborazzi) testDemoImplementation(projects.core.screenshotTesting) + androidTestImplementation(kotlin("test")) androidTestImplementation(projects.core.testing) androidTestImplementation(projects.core.dataTest) androidTestImplementation(projects.core.datastoreTest) androidTestImplementation(libs.androidx.test.espresso.core) androidTestImplementation(libs.androidx.navigation.testing) androidTestImplementation(libs.accompanist.testharness) + androidTestImplementation(libs.bundles.androidx.compose.ui.test) androidTestImplementation(libs.hilt.android.testing) baselineProfile(projects.benchmarks) diff --git a/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt index 52c337521..024ec4fe0 100644 --- a/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt @@ -30,10 +30,6 @@ class AndroidFeatureConventionPlugin : Plugin { apply("nowinandroid.android.hilt") } extensions.configure { - defaultConfig { - testInstrumentationRunner = - "com.google.samples.apps.nowinandroid.core.testing.NiaTestRunner" - } testOptions.animationsDisabled = true configureGradleManagedDevices(this) } diff --git a/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt index be5b41d07..71d818c0c 100644 --- a/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt @@ -40,6 +40,7 @@ class AndroidLibraryConventionPlugin : Plugin { extensions.configure { configureKotlinAndroid(this) defaultConfig.targetSdk = 34 + defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testOptions.animationsDisabled = true configureFlavors(this) configureGradleManagedDevices(this) @@ -52,6 +53,7 @@ class AndroidLibraryConventionPlugin : Plugin { disableUnnecessaryAndroidTests(target) } dependencies { + add("androidTestImplementation", kotlin("test")) add("testImplementation", kotlin("test")) add("implementation", libs.findLibrary("androidx.tracing.ktx").get()) diff --git a/core/database/build.gradle.kts b/core/database/build.gradle.kts index 4a6bcb66a..a9e38ead7 100644 --- a/core/database/build.gradle.kts +++ b/core/database/build.gradle.kts @@ -22,10 +22,6 @@ plugins { } android { - defaultConfig { - testInstrumentationRunner = - "com.google.samples.apps.nowinandroid.core.testing.NiaTestRunner" - } namespace = "com.google.samples.apps.nowinandroid.core.database" } @@ -34,5 +30,7 @@ dependencies { implementation(libs.kotlinx.datetime) - androidTestImplementation(projects.core.testing) + androidTestImplementation(libs.androidx.test.core) + androidTestImplementation(libs.androidx.test.runner) + androidTestImplementation(libs.kotlinx.coroutines.test) } diff --git a/core/designsystem/build.gradle.kts b/core/designsystem/build.gradle.kts index 548e635bb..a8d6ea9c5 100644 --- a/core/designsystem/build.gradle.kts +++ b/core/designsystem/build.gradle.kts @@ -43,10 +43,7 @@ dependencies { testImplementation(libs.accompanist.testharness) testImplementation(libs.hilt.android.testing) testImplementation(libs.robolectric) - testImplementation(libs.roborazzi) testImplementation(projects.core.screenshotTesting) - testImplementation(projects.core.testing) - androidTestImplementation(libs.androidx.compose.ui.test) - androidTestImplementation(projects.core.testing) + androidTestImplementation(libs.bundles.androidx.compose.ui.test) } diff --git a/core/screenshot-testing/build.gradle.kts b/core/screenshot-testing/build.gradle.kts index 4e9a931b0..95d50e0bf 100644 --- a/core/screenshot-testing/build.gradle.kts +++ b/core/screenshot-testing/build.gradle.kts @@ -24,11 +24,10 @@ android { } dependencies { + api(libs.androidx.activity.compose) api(libs.roborazzi) + api(libs.robolectric) + api(libs.bundles.androidx.compose.ui.test) implementation(libs.accompanist.testharness) - implementation(libs.androidx.activity.compose) - implementation(libs.androidx.compose.ui.test) - implementation(libs.robolectric) - implementation(projects.core.common) implementation(projects.core.designsystem) } diff --git a/core/testing/build.gradle.kts b/core/testing/build.gradle.kts index 02729ceff..90f2405a4 100644 --- a/core/testing/build.gradle.kts +++ b/core/testing/build.gradle.kts @@ -15,7 +15,6 @@ */ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.library.compose) alias(libs.plugins.nowinandroid.android.hilt) } @@ -24,19 +23,15 @@ android { } dependencies { - api(kotlin("test")) - api(libs.androidx.compose.ui.test) + api(libs.kotlinx.coroutines.test) api(projects.core.analytics) + api(projects.core.common) api(projects.core.data) api(projects.core.model) api(projects.core.notifications) - debugApi(libs.androidx.compose.ui.testManifest) implementation(libs.androidx.test.rules) implementation(libs.hilt.android.testing) - implementation(libs.kotlinx.coroutines.test) implementation(libs.kotlinx.datetime) - implementation(projects.core.common) - implementation(projects.core.designsystem) } diff --git a/core/ui/build.gradle.kts b/core/ui/build.gradle.kts index 5d8a65d44..5606cb5d1 100644 --- a/core/ui/build.gradle.kts +++ b/core/ui/build.gradle.kts @@ -20,9 +20,6 @@ plugins { } android { - defaultConfig { - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } namespace = "com.google.samples.apps.nowinandroid.core.ui" } @@ -36,5 +33,6 @@ dependencies { implementation(libs.coil.kt) implementation(libs.coil.kt.compose) + androidTestImplementation(libs.bundles.androidx.compose.ui.test) androidTestImplementation(projects.core.testing) } diff --git a/feature/bookmarks/build.gradle.kts b/feature/bookmarks/build.gradle.kts index 4e97176a2..51a15ce7a 100644 --- a/feature/bookmarks/build.gradle.kts +++ b/feature/bookmarks/build.gradle.kts @@ -29,5 +29,6 @@ dependencies { testImplementation(projects.core.testing) + androidTestImplementation(libs.bundles.androidx.compose.ui.test) androidTestImplementation(projects.core.testing) } diff --git a/feature/foryou/build.gradle.kts b/feature/foryou/build.gradle.kts index fd41d9a13..004fe8ad6 100644 --- a/feature/foryou/build.gradle.kts +++ b/feature/foryou/build.gradle.kts @@ -33,8 +33,8 @@ dependencies { testImplementation(libs.hilt.android.testing) testImplementation(libs.robolectric) testImplementation(projects.core.testing) - testImplementation(projects.core.screenshotTesting) - testDemoImplementation(libs.roborazzi) + testDemoImplementation(projects.core.screenshotTesting) + androidTestImplementation(libs.bundles.androidx.compose.ui.test) androidTestImplementation(projects.core.testing) } diff --git a/feature/interests/build.gradle.kts b/feature/interests/build.gradle.kts index ee6aaf122..ca91ba2c4 100644 --- a/feature/interests/build.gradle.kts +++ b/feature/interests/build.gradle.kts @@ -29,5 +29,6 @@ dependencies { testImplementation(projects.core.testing) + androidTestImplementation(libs.bundles.androidx.compose.ui.test) androidTestImplementation(projects.core.testing) } diff --git a/feature/search/build.gradle.kts b/feature/search/build.gradle.kts index 98052e9ab..c5f1f6ad0 100644 --- a/feature/search/build.gradle.kts +++ b/feature/search/build.gradle.kts @@ -31,6 +31,7 @@ dependencies { testImplementation(projects.core.testing) + androidTestImplementation(libs.bundles.androidx.compose.ui.test) androidTestImplementation(projects.core.testing) } diff --git a/feature/settings/build.gradle.kts b/feature/settings/build.gradle.kts index 4b9a72bdd..15d65204d 100644 --- a/feature/settings/build.gradle.kts +++ b/feature/settings/build.gradle.kts @@ -31,5 +31,5 @@ dependencies { testImplementation(projects.core.testing) - androidTestImplementation(projects.core.testing) + androidTestImplementation(libs.bundles.androidx.compose.ui.test) } diff --git a/feature/topic/build.gradle.kts b/feature/topic/build.gradle.kts index d457b2f73..726920af1 100644 --- a/feature/topic/build.gradle.kts +++ b/feature/topic/build.gradle.kts @@ -29,5 +29,6 @@ dependencies { testImplementation(projects.core.testing) + androidTestImplementation(libs.bundles.androidx.compose.ui.test) androidTestImplementation(projects.core.testing) } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 26da6907d..2c1236d9d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -59,6 +59,9 @@ secrets = "2.0.1" truth = "1.4.2" turbine = "1.0.0" +[bundles] +androidx-compose-ui-test = ["androidx-compose-ui-test", "androidx-compose-ui-testManifest"] + [libraries] accompanist-permissions = { group = "com.google.accompanist", name = "accompanist-permissions", version.ref = "accompanist" } accompanist-testharness = { group = "com.google.accompanist", name = "accompanist-testharness", version.ref = "accompanist" }