From 93b10d5732ea753c53f38bb393db810c46c230f4 Mon Sep 17 00:00:00 2001 From: GerardPaligot Date: Tue, 10 Dec 2024 13:52:23 +0100 Subject: [PATCH] chore(gradle): create test plugin convention for test modules. --- build-logic/plugins/build.gradle.kts | 4 +++ .../kotlin/conventions/TestLibraryPlugin.kt | 29 +++++++++++++++++++ .../schedules/schedules-test/build.gradle.kts | 11 +------ .../speakers/speakers-test/build.gradle.kts | 11 +------ 4 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 build-logic/plugins/src/main/kotlin/conventions/TestLibraryPlugin.kt diff --git a/build-logic/plugins/build.gradle.kts b/build-logic/plugins/build.gradle.kts index 42532b617..e429f80f0 100644 --- a/build-logic/plugins/build.gradle.kts +++ b/build-logic/plugins/build.gradle.kts @@ -64,6 +64,10 @@ gradlePlugin { id = "confily.test.scopes" implementationClass = "conventions.TestScopesLibraryPlugin" } + register("testLibrary") { + id = "confily.test" + implementationClass = "conventions.TestLibraryPlugin" + } register("androidWearLibrary") { id = "confily.android.wear.library" implementationClass = "AndroidWearLibraryPlugin" diff --git a/build-logic/plugins/src/main/kotlin/conventions/TestLibraryPlugin.kt b/build-logic/plugins/src/main/kotlin/conventions/TestLibraryPlugin.kt new file mode 100644 index 000000000..5c13bc7e4 --- /dev/null +++ b/build-logic/plugins/src/main/kotlin/conventions/TestLibraryPlugin.kt @@ -0,0 +1,29 @@ +package conventions + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.getByType +import org.jetbrains.compose.ComposeExtension +import org.jetbrains.compose.ExperimentalComposeLibrary + +class TestLibraryPlugin: Plugin { + @OptIn(ExperimentalComposeLibrary::class) + override fun apply(target: Project) { + with(target) { + with(pluginManager) { + apply("confily.android.library") + apply("confily.android.library.compose") + apply("confily.quality") + } + val libs = extensions.getByType().named("libs") + val compose = extensions.getByType() + dependencies { + add("api", project(":android-core:core-test-patterns")) + add("api", libs.findLibrary("androidx-espresso-core").get()) + add("api", compose.dependencies.uiTestJUnit4) + } + } + } +} diff --git a/features/schedules/schedules-test/build.gradle.kts b/features/schedules/schedules-test/build.gradle.kts index 2760f33c5..aacab5632 100644 --- a/features/schedules/schedules-test/build.gradle.kts +++ b/features/schedules/schedules-test/build.gradle.kts @@ -1,11 +1,5 @@ -@file:OptIn(ExperimentalComposeLibrary::class) - -import org.jetbrains.compose.ExperimentalComposeLibrary - plugins { - id("confily.android.library") - id("confily.android.library.compose") - id("confily.quality") + id("confily.test") } android { @@ -14,7 +8,4 @@ android { dependencies { api(projects.features.schedules.schedulesTestScopes) - api(projects.androidCore.coreTestPatterns) - api(libs.androidx.espresso.core) - api(compose.uiTestJUnit4) } diff --git a/features/speakers/speakers-test/build.gradle.kts b/features/speakers/speakers-test/build.gradle.kts index f15f2a812..9637627b1 100644 --- a/features/speakers/speakers-test/build.gradle.kts +++ b/features/speakers/speakers-test/build.gradle.kts @@ -1,11 +1,5 @@ -@file:OptIn(ExperimentalComposeLibrary::class) - -import org.jetbrains.compose.ExperimentalComposeLibrary - plugins { - id("confily.android.library") - id("confily.android.library.compose") - id("confily.quality") + id("confily.test") } android { @@ -14,7 +8,4 @@ android { dependencies { api(projects.features.speakers.speakersTestScopes) - api(projects.androidCore.coreTestPatterns) - api(libs.androidx.espresso.core) - api(compose.uiTestJUnit4) }