Skip to content

Commit

Permalink
Cleanup dependencies
Browse files Browse the repository at this point in the history
This is a followup cleanup of android#1163 that was partially addressed by android#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.
  • Loading branch information
SimonMarquis committed Mar 21, 2024
1 parent bd89507 commit 930e061
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 31 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ class AndroidFeatureConventionPlugin : Plugin<Project> {
apply("nowinandroid.android.hilt")
}
extensions.configure<LibraryExtension> {
defaultConfig {
testInstrumentationRunner =
"com.google.samples.apps.nowinandroid.core.testing.NiaTestRunner"
}
testOptions.animationsDisabled = true
configureGradleManagedDevices(this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
extensions.configure<LibraryExtension> {
configureKotlinAndroid(this)
defaultConfig.targetSdk = 34
defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testOptions.animationsDisabled = true
configureFlavors(this)
configureGradleManagedDevices(this)
Expand All @@ -52,6 +53,7 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
disableUnnecessaryAndroidTests(target)
}
dependencies {
add("androidTestImplementation", kotlin("test"))
add("testImplementation", kotlin("test"))

add("implementation", libs.findLibrary("androidx.tracing.ktx").get())
Expand Down
8 changes: 3 additions & 5 deletions core/database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ plugins {
}

android {
defaultConfig {
testInstrumentationRunner =
"com.google.samples.apps.nowinandroid.core.testing.NiaTestRunner"
}
namespace = "com.google.samples.apps.nowinandroid.core.database"
}

Expand All @@ -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)
}
5 changes: 1 addition & 4 deletions core/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
7 changes: 3 additions & 4 deletions core/screenshot-testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
9 changes: 2 additions & 7 deletions core/testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
plugins {
alias(libs.plugins.nowinandroid.android.library)
alias(libs.plugins.nowinandroid.android.library.compose)
alias(libs.plugins.nowinandroid.android.hilt)
}

Expand All @@ -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)
}
4 changes: 1 addition & 3 deletions core/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ plugins {
}

android {
defaultConfig {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
namespace = "com.google.samples.apps.nowinandroid.core.ui"
}

Expand All @@ -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)
}
1 change: 1 addition & 0 deletions feature/bookmarks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ dependencies {

testImplementation(projects.core.testing)

androidTestImplementation(libs.bundles.androidx.compose.ui.test)
androidTestImplementation(projects.core.testing)
}
4 changes: 2 additions & 2 deletions feature/foryou/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
1 change: 1 addition & 0 deletions feature/interests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ dependencies {

testImplementation(projects.core.testing)

androidTestImplementation(libs.bundles.androidx.compose.ui.test)
androidTestImplementation(projects.core.testing)
}
1 change: 1 addition & 0 deletions feature/search/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies {

testImplementation(projects.core.testing)

androidTestImplementation(libs.bundles.androidx.compose.ui.test)
androidTestImplementation(projects.core.testing)
}

2 changes: 1 addition & 1 deletion feature/settings/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ dependencies {

testImplementation(projects.core.testing)

androidTestImplementation(projects.core.testing)
androidTestImplementation(libs.bundles.androidx.compose.ui.test)
}
1 change: 1 addition & 0 deletions feature/topic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ dependencies {

testImplementation(projects.core.testing)

androidTestImplementation(libs.bundles.androidx.compose.ui.test)
androidTestImplementation(projects.core.testing)
}
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down

0 comments on commit 930e061

Please sign in to comment.