From 7ff1913855ad1db355875502e964d7e12947241b Mon Sep 17 00:00:00 2001 From: Aurimas Liutikas Date: Fri, 8 Aug 2025 10:18:00 -0700 Subject: [PATCH] Fixes host test tasks that were accidentally attemping to run Gradle 9.0.0 has the new enforcement that Test task runs that have sources but no tests run should fail. Without this change we get Execution failed for task ':core:analytics:testDemoDebugUnitTest'. > There are test sources present and no filters are applied, but the test task did not discover any tests to execute. This is likely due to a misconfiguration. Please check your test configuration. If this is not a misconfiguration, this error can be disabled by setting the 'failOnNoDiscoveredTests' property to false. We get this because before this change AndroidCompose was always setting isIncludeAndroidResources = true which generates a source to the test task and in the case of :core:analytics it is the only source. Instead of setting isIncludeAndroidResources in AndroidCompose move to setting it in relevant build.gradle.kts files (most already had it) --- app/build.gradle.kts | 6 +----- .../com/google/samples/apps/nowinandroid/AndroidCompose.kt | 7 ------- core/data/build.gradle.kts | 6 +----- core/designsystem/build.gradle.kts | 1 + core/network/build.gradle.kts | 6 +----- feature/foryou/build.gradle.kts | 1 + 6 files changed, 5 insertions(+), 22 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 682fbc1b3..fe3e2ec49 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -62,11 +62,7 @@ android { excludes.add("/META-INF/{AL2.0,LGPL2.1}") } } - testOptions { - unitTests { - isIncludeAndroidResources = true - } - } + testOptions.unitTests.isIncludeAndroidResources = true namespace = "com.google.samples.apps.nowinandroid" } diff --git a/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/AndroidCompose.kt b/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/AndroidCompose.kt index ed2a5289b..3d050d86b 100644 --- a/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/AndroidCompose.kt +++ b/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/AndroidCompose.kt @@ -42,13 +42,6 @@ internal fun Project.configureAndroidCompose( "implementation"(libs.findLibrary("androidx-compose-ui-tooling-preview").get()) "debugImplementation"(libs.findLibrary("androidx-compose-ui-tooling").get()) } - - testOptions { - unitTests { - // For Robolectric - isIncludeAndroidResources = true - } - } } extensions.configure { diff --git a/core/data/build.gradle.kts b/core/data/build.gradle.kts index 8c839fa8e..c47d4ee58 100644 --- a/core/data/build.gradle.kts +++ b/core/data/build.gradle.kts @@ -22,11 +22,7 @@ plugins { android { namespace = "com.google.samples.apps.nowinandroid.core.data" - testOptions { - unitTests { - isIncludeAndroidResources = true - } - } + testOptions.unitTests.isIncludeAndroidResources = true } dependencies { diff --git a/core/designsystem/build.gradle.kts b/core/designsystem/build.gradle.kts index aac2ddb8f..8a138082b 100644 --- a/core/designsystem/build.gradle.kts +++ b/core/designsystem/build.gradle.kts @@ -22,6 +22,7 @@ plugins { android { namespace = "com.google.samples.apps.nowinandroid.core.designsystem" + testOptions.unitTests.isIncludeAndroidResources = true } dependencies { diff --git a/core/network/build.gradle.kts b/core/network/build.gradle.kts index bf4dd9153..1a902d5d6 100644 --- a/core/network/build.gradle.kts +++ b/core/network/build.gradle.kts @@ -30,11 +30,7 @@ android { buildConfig = true } namespace = "com.google.samples.apps.nowinandroid.core.network" - testOptions { - unitTests { - isIncludeAndroidResources = true - } - } + testOptions.unitTests.isIncludeAndroidResources = true } dependencies { diff --git a/feature/foryou/build.gradle.kts b/feature/foryou/build.gradle.kts index 59f6844cf..de1af7540 100644 --- a/feature/foryou/build.gradle.kts +++ b/feature/foryou/build.gradle.kts @@ -23,6 +23,7 @@ plugins { android { namespace = "com.google.samples.apps.nowinandroid.feature.foryou" + testOptions.unitTests.isIncludeAndroidResources = true } dependencies {