Refined the Compose dependencies.

* Refactored the dependencies to be included only in the modules where they are required.
* Removed unnecessary dependencies from the project.
This commit is contained in:
MohitMaliFtechiz 2025-03-04 12:27:42 +05:30 committed by Kelson
parent 1743d7b231
commit 5ea7e86277
7 changed files with 31 additions and 52 deletions

View File

@ -127,7 +127,6 @@ androidComponents {
} }
dependencies { dependencies {
androidTestImplementation(Libs.ANDROIDX_COMPOSE_UI_TEST_JUNIT4)
androidTestImplementation(Libs.leakcanary_android_instrumentation) androidTestImplementation(Libs.leakcanary_android_instrumentation)
testImplementation(Libs.kotlinx_coroutines_test) testImplementation(Libs.kotlinx_coroutines_test)
} }

View File

@ -17,7 +17,7 @@ buildscript {
} }
plugins { plugins {
buildSrcVersions buildSrcVersions
id("org.jetbrains.kotlin.plugin.compose") version Versions.ORG_JETBRAINS_KOTLIN_PLUGIN_COMPOSE apply false id("org.jetbrains.kotlin.plugin.compose") version Versions.org_jetbrains_kotlin apply false
} }
allprojects { allprojects {

View File

@ -368,44 +368,29 @@ object Libs {
const val fetchOkhttp: String = "com.github.tonyofrancis.Fetch:fetch2okhttp:" + Versions.fetch const val fetchOkhttp: String = "com.github.tonyofrancis.Fetch:fetch2okhttp:" + Versions.fetch
/** /**
* https://developer.android.com/reference/kotlin/androidx/compose/material3 * https://developer.android.com/jetpack/androidx/releases/compose-material3
*/ */
const val ANDROIDX_COMPOSE_MATERIAL3: String = const val COMPOSE_MATERIAL3: String =
"androidx.compose.material3:material3-android:" + Versions.ANDROIDX_COMPOSE_MATERIAL3_VERSION "androidx.compose.material3:material3:${Versions.COMPOSE_MATERIAL3}"
/** /**
* https://developer.android.com/reference/kotlin/androidx/activity/compose * https://developer.android.com/reference/kotlin/androidx/activity/compose
*/ */
const val ANDROIDX_ACTIVITY_COMPOSE: String = const val ANDROIDX_ACTIVITY_COMPOSE: String =
"androidx.activity:activity-compose:" + Versions.ANDROIDX_ACTIVITY_COMPOSE_VERSION "androidx.activity:activity-compose:${Versions.COMPOSE_ACTIVITY_VERSION}"
/** const val COMPOSE_TOOLING_PREVIEW =
* https://developer.android.com/develop/ui/compose/documentation "androidx.compose.ui:ui-tooling-preview:${Versions.COMPOSE_VERSION}"
*/
const val ANDROIDX_COMPOSE_UI: String =
"androidx.compose.ui:ui:" + Versions.ANDROIDX_COMPOSE_UI_VERSION
const val ANDROIDX_COMPOSE_BOM: String = const val COMPOSE_TOOLING = "androidx.compose.ui:ui-tooling:${Versions.COMPOSE_VERSION}"
"androidx.compose:compose-bom:" + Versions.ANDROIDX_COMPOSE_BOM_VERSION
const val ANDROIDX_COMPOSE_TOOLING_PREVIEW: String = const val COMPOSE_UI_TEST_JUNIT = "androidx.compose.ui:ui-test-junit4:${Versions.COMPOSE_VERSION}"
"androidx.compose.ui:ui-tooling-preview"
const val ANDROIDX_COMPOSE_RUNTIME_LIVEDATA: String = const val COMPOSE_UI_MANIFEST = "androidx.compose.ui:ui-test-manifest:${Versions.COMPOSE_VERSION}"
"androidx.compose.runtime:runtime-livedata"
const val ANDROIDX_COMPOSE_RUNTIME_RXJAVA2: String = const val COMPOSE_RX_JAVA2 =
"androidx.compose.runtime:runtime-rxjava2" "androidx.compose.runtime:runtime-rxjava2:${Versions.COMPOSE_VERSION}"
/** const val COMPOSE_LIVE_DATA =
* testing libraries for compose "androidx.compose.runtime:runtime-livedata:${Versions.COMPOSE_VERSION}"
*/
const val ANDROIDX_COMPOSE_UI_TEST_JUNIT4: String =
"androidx.compose.ui:ui-test-junit4:${Versions.ANDROIDX_COMPOSE_UI_VERSION}"
const val ANDROIDX_COMPOSE_UI_TOOLING: String =
"androidx.compose.ui:ui-tooling"
const val ANDROIDX_COMPOSE_UI_TEST_MANIFEST =
"androidx.compose.ui:ui-test-manifest:${Versions.ANDROIDX_COMPOSE_UI_VERSION}"
} }

View File

@ -116,17 +116,11 @@ object Versions {
const val fetch: String = "3.4.1" const val fetch: String = "3.4.1"
const val ORG_JETBRAINS_KOTLIN_PLUGIN_COMPOSE = "2.1.10" const val COMPOSE_ACTIVITY_VERSION = "1.10.0"
const val KOTLIN_COMPILER_EXTENSION_VERSION = "1.5.15" const val COMPOSE_VERSION = "1.7.8"
const val ANDROIDX_COMPOSE_MATERIAL3_VERSION = "1.3.1" const val COMPOSE_MATERIAL3 = "1.3.1"
const val ANDROIDX_ACTIVITY_COMPOSE_VERSION = "1.10.0"
const val ANDROIDX_COMPOSE_UI_VERSION = "1.7.7"
const val ANDROIDX_COMPOSE_BOM_VERSION = "2025.01.01"
} }
/** /**

View File

@ -20,6 +20,7 @@ package plugin
import Config import Config
import Libs import Libs
import Versions
import com.android.build.api.dsl.CommonExtension import com.android.build.api.dsl.CommonExtension
import com.android.build.gradle.BaseExtension import com.android.build.gradle.BaseExtension
import io.gitlab.arturbosch.detekt.extensions.DetektExtension import io.gitlab.arturbosch.detekt.extensions.DetektExtension
@ -94,10 +95,6 @@ class AllProjectConfigurer {
compose = true compose = true
} }
composeOptions {
kotlinCompilerExtensionVersion = Versions.KOTLIN_COMPILER_EXTENSION_VERSION
}
testOptions { testOptions {
execution = "ANDROIDX_TEST_ORCHESTRATOR" execution = "ANDROIDX_TEST_ORCHESTRATOR"
unitTests.apply { unitTests.apply {
@ -241,14 +238,19 @@ class AllProjectConfigurer {
implementation(Libs.fetch) implementation(Libs.fetch)
implementation(Libs.fetchOkhttp) implementation(Libs.fetchOkhttp)
implementation(Libs.androidx_activity) implementation(Libs.androidx_activity)
androidTestImplementation(Libs.leakcanary_android_instrumentation)
// compose // compose
implementation(Libs.ANDROIDX_COMPOSE_MATERIAL3) implementation(Libs.COMPOSE_MATERIAL3)
implementation(Libs.ANDROIDX_ACTIVITY_COMPOSE) implementation(Libs.ANDROIDX_ACTIVITY_COMPOSE)
implementation(Libs.ANDROIDX_COMPOSE_UI) implementation(Libs.COMPOSE_TOOLING_PREVIEW)
implementation(Libs.ANDROIDX_COMPOSE_UI_TOOLING) implementation(Libs.COMPOSE_RX_JAVA2)
implementation(Libs.ANDROIDX_COMPOSE_RUNTIME_LIVEDATA) implementation(Libs.COMPOSE_LIVE_DATA)
implementation(Libs.ANDROIDX_COMPOSE_RUNTIME_RXJAVA2)
// Compose UI test implementation
androidTestImplementation(Libs.COMPOSE_UI_TEST_JUNIT)
debugImplementation(Libs.COMPOSE_UI_MANIFEST)
debugImplementation(Libs.COMPOSE_TOOLING)
} }
} }
} }

View File

@ -54,6 +54,9 @@ internal fun DependencyHandlerScope.ksp(dependency: String) =
internal fun DependencyHandlerScope.testImplementation(dependency: String) = internal fun DependencyHandlerScope.testImplementation(dependency: String) =
addDependency("testImplementation", dependency) addDependency("testImplementation", dependency)
internal fun DependencyHandlerScope.debugImplementation(dependency: String) =
addDependency("debugImplementation", dependency)
internal fun DependencyHandlerScope.implementation(dependency: String) = internal fun DependencyHandlerScope.implementation(dependency: String) =
addDependency("implementation", dependency) addDependency("implementation", dependency)

View File

@ -63,8 +63,4 @@ dependencies {
implementation(Libs.kotlinx_coroutines_android) implementation(Libs.kotlinx_coroutines_android)
implementation(Libs.kotlinx_coroutines_rx3) implementation(Libs.kotlinx_coroutines_rx3)
implementation(Libs.zxing) implementation(Libs.zxing)
implementation(platform(Libs.ANDROIDX_COMPOSE_BOM))
// For Compose UI Testing
debugImplementation(Libs.ANDROIDX_COMPOSE_UI_TOOLING)
debugImplementation(Libs.ANDROIDX_COMPOSE_UI_TEST_MANIFEST)
} }