From 291c75a685b23a5055501c5e7bd498c5faf26ece Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Fri, 1 Mar 2024 22:15:59 +0100 Subject: [PATCH] Start using Gradle Version Catalog in appcompose Version Catalog will have to be applied to all other modules when old app package is deleted --- appcompose/build.gradle | 41 +++++++----------------------------- gradle/libs.versions.toml | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 34 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/appcompose/build.gradle b/appcompose/build.gradle index f3ca7e62..bb6edf92 100644 --- a/appcompose/build.gradle +++ b/appcompose/build.gradle @@ -68,50 +68,23 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - def composeBom = platform('androidx.compose:compose-bom:2024.02.01') - implementation composeBom - androidTestImplementation composeBom + implementation(libs.bundles.compose) + implementation(libs.compose.activity) implementation 'androidx.palette:palette-ktx:1.0.0' - implementation 'androidx.activity:activity-compose:1.8.2' - implementation 'androidx.compose.material3:material3' - implementation "com.google.accompanist:accompanist-swiperefresh:0.30.1" - def voyager = "1.0.0" - implementation "cafe.adriel.voyager:voyager-navigator:$voyager" - implementation "cafe.adriel.voyager:voyager-tab-navigator:$voyager" - implementation "cafe.adriel.voyager:voyager-koin:$voyager" - implementation "cafe.adriel.voyager:voyager-transitions:$voyager" + implementation(libs.bundles.voyager) + implementation(libs.bundles.lifecycle) + implementation(libs.bundles.coil) - def tooling = "1.6.2" - debugImplementation "androidx.compose.ui:ui-tooling:$tooling" - implementation "androidx.compose.ui:ui-tooling-preview:$tooling" - - def lifecycle_version = "2.7.0" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version" - implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version" - - /*def koin_version = "3.3.3" - implementation "io.insert-koin:koin-core:$koin_version" - implementation "io.insert-koin:koin-android:$koin_version" - implementation "io.insert-koin:koin-androidx-compose:3.4.2"*/ + implementation(libs.bundles.coroutines) + androidTestImplementation(libs.coroutines.test) androidTestImplementation "io.insert-koin:koin-test-junit4:$rootProject.ext.koin_version" androidTestImplementation "io.insert-koin:koin-test:$rootProject.ext.koin_version" androidTestImplementation 'com.squareup.okhttp3:mockwebserver:4.9.0' - implementation "io.coil-kt:coil:2.4.0" - implementation "io.coil-kt:coil-compose:2.4.0" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3" - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3' - androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3" - - def lifecycle = "2.7.0" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle" - implementation "androidx.lifecycle:lifecycle-runtime-compose:$lifecycle" } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..566005de --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,44 @@ +[versions] +compose-bom = "2024.02.01" +voyager = "1.0.0" +lifecycle = "2.7.0" +coil = "2.4.0" +coroutines = "1.8.0" + +[libraries] +bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" } +compose-foundation = { module = "androidx.compose.foundation:foundation" } +compose-runtime = { module = "androidx.compose.runtime:runtime" } +compose-animation = { module = "androidx.compose.animation:animation" } +compose-ui = { module = "androidx.compose.ui:ui" } +compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } +compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } +# specify material3 version is required for gradle to find the dependency +compose-material3 = { module = "androidx.compose.material3:material3", version = "1.2.0" } +compose-activity = "androidx.activity:activity-compose:1.8.2" + +voyager-navigator = { module = "cafe.adriel.voyager:voyager-navigator", version.ref = "voyager" } +voyager-tab-navigator = { module = "cafe.adriel.voyager:voyager-tab-navigator", version.ref = "voyager" } +voyager-koin = { module = "cafe.adriel.voyager:voyager-koin", version.ref = "voyager" } +voyager-transitions = { module = "cafe.adriel.voyager:voyager-transitions", version.ref = "voyager" } + +lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle" } +lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycle" } +lifecycle-viewmodel-savedstate = { module = "androidx.lifecycle:lifecycle-viewmodel-savedstate", version.ref = "lifecycle" } +lifecyle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycle" } + +coil-core = { module = "io.coil-kt:coil", version.ref = "coil" } +coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" } + +coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } +coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" } +coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } + +[bundles] +compose = ["bom", "compose-foundation", "compose-runtime", "compose-animation", + "compose-ui", "compose-ui-tooling", "compose-ui-tooling-preview", "compose-material3"] +voyager = ["voyager-navigator", "voyager-tab-navigator", "voyager-koin", "voyager-transitions"] +lifecycle = ["lifecycle-viewmodel-ktx", "lifecycle-viewmodel-compose", "lifecycle-viewmodel-savedstate", + "lifecyle-runtime-compose"] +coil = ["coil-core", "coil-compose"] +coroutines = ["coroutines-core", "coroutines-android"]