From c9e41a8cb055f1fba0789a5d7d183a224a9ca3cd Mon Sep 17 00:00:00 2001 From: F0x1d Date: Tue, 9 Jul 2024 00:15:14 +0300 Subject: [PATCH] [build]: some final improvements --- app/build.gradle.kts | 18 ------------- .../main/kotlin/extensions/Dependencies.kt | 27 +++++++++++++++++++ .../AndroidApplicationConventionPlugin.kt | 4 +++ .../AndroidComposeFeatureConventionPlugin.kt | 9 ++----- .../feature/AndroidFeatureConventionPlugin.kt | 16 ++--------- 5 files changed, 35 insertions(+), 39 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5ae44ab8..16c6fad3 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -15,21 +15,6 @@ android { } dependencies { - implementation(project(":data")) - implementation(project(":strings")) - - implementation(project(":core:core-arch")) - implementation(project(":core:core-context")) - implementation(project(":core:core-database")) - implementation(project(":core:core-datetime")) - implementation(project(":core:core-intents")) - implementation(project(":core:core-io")) - implementation(project(":core:core-navigation")) - implementation(project(":core:core-preferences")) - implementation(project(":core:core-terminals")) - implementation(project(":core:core-ui")) - implementation(project(":core:core-ui-compose")) - implementation(project(":feature:feature-crashes")) implementation(project(":feature:feature-crashes-core")) implementation(project(":feature:feature-filters")) @@ -57,7 +42,4 @@ dependencies { implementation(libs.material) implementation(libs.bundles.androidx.navigation) - - androidTestImplementation(libs.androidx.test.ext.junit) - androidTestImplementation(libs.androidx.test.espresso.core) } diff --git a/build-logic/convention/src/main/kotlin/extensions/Dependencies.kt b/build-logic/convention/src/main/kotlin/extensions/Dependencies.kt index 51302b6b..1837aef7 100644 --- a/build-logic/convention/src/main/kotlin/extensions/Dependencies.kt +++ b/build-logic/convention/src/main/kotlin/extensions/Dependencies.kt @@ -2,6 +2,28 @@ package extensions import org.gradle.api.artifacts.Dependency import org.gradle.kotlin.dsl.DependencyHandlerScope +import org.gradle.kotlin.dsl.project + +internal fun DependencyHandlerScope.coreDependencies(withCompose: Boolean = true) { + implementation(project(":data")) + implementation(project(":strings")) + + implementation(project(":core:core-arch")) + implementation(project(":core:core-context")) + implementation(project(":core:core-database")) + implementation(project(":core:core-datetime")) + implementation(project(":core:core-intents")) + implementation(project(":core:core-io")) + implementation(project(":core:core-navigation")) + implementation(project(":core:core-preferences")) + implementation(project(":core:core-terminals")) + implementation(project(":core:core-ui")) + + if (withCompose) { + implementation(project(":core:core-ui-compose")) + testImplementation(project(":core:core-tests")) + } +} internal fun DependencyHandlerScope.implementation(dependency: Any): Dependency? = add( configurationName = "implementation", @@ -18,6 +40,11 @@ internal fun DependencyHandlerScope.testImplementation(dependency: Any): Depende dependencyNotation = dependency, ) +internal fun DependencyHandlerScope.androidTestImplementation(dependency: Any): Dependency? = add( + configurationName = "androidTestImplementation", + dependencyNotation = dependency, +) + internal fun DependencyHandlerScope.implementation(bundle: List): List = bundle.map { add( configurationName = "implementation", diff --git a/build-logic/convention/src/main/kotlin/main/AndroidApplicationConventionPlugin.kt b/build-logic/convention/src/main/kotlin/main/AndroidApplicationConventionPlugin.kt index bfb601d5..c9b32f96 100644 --- a/build-logic/convention/src/main/kotlin/main/AndroidApplicationConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/main/AndroidApplicationConventionPlugin.kt @@ -3,11 +3,13 @@ package main import com.android.build.api.dsl.ApplicationExtension import extensions.configureKotlinAndroid import extensions.configureRobolectric +import extensions.coreDependencies import extensions.pluginId import extensions.version import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies class AndroidApplicationConventionPlugin : Plugin { override fun apply(target: Project) = with(target) { @@ -64,5 +66,7 @@ class AndroidApplicationConventionPlugin : Plugin { } } } + + dependencies { coreDependencies() } } } diff --git a/build-logic/convention/src/main/kotlin/main/feature/AndroidComposeFeatureConventionPlugin.kt b/build-logic/convention/src/main/kotlin/main/feature/AndroidComposeFeatureConventionPlugin.kt index cb97bf46..d7de19df 100644 --- a/build-logic/convention/src/main/kotlin/main/feature/AndroidComposeFeatureConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/main/feature/AndroidComposeFeatureConventionPlugin.kt @@ -1,7 +1,6 @@ package main.feature -import extensions.implementation -import extensions.testImplementation +import extensions.coreDependencies import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.dependencies @@ -14,10 +13,6 @@ class AndroidComposeFeatureConventionPlugin : Plugin { apply("logfox.android.unitTests") } - dependencies { - implementation(project(":core:core-ui-compose")) - - testImplementation(project(":core:core-tests")) - } + dependencies { coreDependencies() } } } diff --git a/build-logic/convention/src/main/kotlin/main/feature/AndroidFeatureConventionPlugin.kt b/build-logic/convention/src/main/kotlin/main/feature/AndroidFeatureConventionPlugin.kt index 1eb19534..78023b90 100644 --- a/build-logic/convention/src/main/kotlin/main/feature/AndroidFeatureConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/main/feature/AndroidFeatureConventionPlugin.kt @@ -1,13 +1,13 @@ package main.feature import extensions.bundle +import extensions.coreDependencies import extensions.implementation import extensions.ksp import extensions.library import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.dependencies -import org.gradle.kotlin.dsl.project class AndroidFeatureConventionPlugin : Plugin { override fun apply(target: Project) = with(target) { @@ -17,19 +17,7 @@ class AndroidFeatureConventionPlugin : Plugin { } dependencies { - implementation(project(":data")) - implementation(project(":strings")) - - implementation(project(":core:core-arch")) - implementation(project(":core:core-context")) - implementation(project(":core:core-database")) - implementation(project(":core:core-datetime")) - implementation(project(":core:core-intents")) - implementation(project(":core:core-io")) - implementation(project(":core:core-navigation")) - implementation(project(":core:core-preferences")) - implementation(project(":core:core-terminals")) - implementation(project(":core:core-ui")) + coreDependencies(withCompose = false) implementation(library("material")) implementation(bundle("androidx"))