From f31db821f63d25b02966e4e97cfbdbdd9c33e8e7 Mon Sep 17 00:00:00 2001 From: Ryan Conway Date: Mon, 4 Nov 2024 18:16:20 +0700 Subject: [PATCH 1/6] [#586] Migrate to version catalog --- template-compose/app/build.gradle.kts | 69 +++------ template-compose/build.gradle.kts | 18 ++- .../buildSrc/src/main/java/Dependencies.kt | 71 --------- .../buildSrc/src/main/java/Plugins.kt | 16 -- .../buildSrc/src/main/java/Versions.kt | 39 ----- template-compose/data/build.gradle.kts | 46 ++---- template-compose/domain/build.gradle.kts | 22 +-- template-compose/gradle/libs.versions.toml | 143 ++++++++++++++++++ 8 files changed, 194 insertions(+), 230 deletions(-) delete mode 100644 template-compose/buildSrc/src/main/java/Dependencies.kt delete mode 100644 template-compose/buildSrc/src/main/java/Plugins.kt create mode 100644 template-compose/gradle/libs.versions.toml diff --git a/template-compose/app/build.gradle.kts b/template-compose/app/build.gradle.kts index 54b11d1ee..d97585565 100644 --- a/template-compose/app/build.gradle.kts +++ b/template-compose/app/build.gradle.kts @@ -1,12 +1,12 @@ import org.jetbrains.kotlin.konan.properties.loadProperties plugins { - id(Plugins.ANDROID_APPLICATION) - id(Plugins.KOTLIN_ANDROID) - id(Plugins.KOTLIN_KAPT) - id(Plugins.KOTLIN_PARCELIZE) - id(Plugins.HILT_ANDROID) - id(Plugins.KOVER) + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.kapt) + alias(libs.plugins.kotlin.parcelize) + alias(libs.plugins.hilt) + alias(libs.plugins.kover) } val signingProperties = loadProperties("$rootDir/signing.properties") @@ -133,54 +133,25 @@ dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) - with(Dependencies.AndroidX) { - implementation(CORE_KTX) - implementation(LIFECYCLE_RUNTIME_KTX) - implementation(LIFECYCLE_RUNTIME_COMPOSE) - implementation(DATASTORE_PREFERENCES) - } - - with(Dependencies.Compose) { - implementation(platform(BOM)) - implementation(UI) - debugImplementation(UI_TOOLING) - implementation(UI_TOOLING_PREVIEW) - implementation(MATERIAL) - implementation(NAVIGATION) - - implementation(ACCOMPANIST_PERMISSIONS) - } + implementation(libs.bundles.androidx) - with(Dependencies.Hilt) { - implementation(ANDROID) - implementation(NAVIGATION_COMPOSE) - kapt(COMPILER) - } + implementation(platform(libs.compose.bom)) + implementation(libs.bundles.compose) + debugImplementation(libs.compose.ui.tooling) - with(Dependencies.Log) { - implementation(TIMBER) + implementation(libs.bundles.hilt) + kapt(libs.hilt.compiler) - debugImplementation(CHUCKER) - releaseImplementation(CHUCKER_NO_OP) - } + implementation(libs.timber) + debugImplementation(libs.chucker) + releaseImplementation(libs.chucker.no.op) - with(Dependencies.Util) { - implementation(COMMON_KTX) - } + implementation(libs.nimble.common) - with(Dependencies.Test) { - // Unit test - testImplementation(COROUTINES) - testImplementation(JUNIT) - testImplementation(KOTEST) - testImplementation(MOCKK) - testImplementation(TURBINE) - - // UI test with Robolectric - testImplementation(platform(Dependencies.Compose.BOM)) - testImplementation(COMPOSE_UI_TEST_JUNIT) - testImplementation(ROBOLECTRIC) - } + testImplementation(libs.bundles.unitTest) + testImplementation(libs.test.turbine) + testImplementation(platform(libs.compose.bom)) + testImplementation(libs.bundles.implementationTest) } /* diff --git a/template-compose/build.gradle.kts b/template-compose/build.gradle.kts index 9319cd7ef..a921449aa 100644 --- a/template-compose/build.gradle.kts +++ b/template-compose/build.gradle.kts @@ -1,12 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id(Plugins.ANDROID_APPLICATION) version Versions.GRADLE apply false - id(Plugins.ANDROID_LIBRARY) version Versions.GRADLE apply false - id(Plugins.KOTLIN_JVM) version Versions.KOTLIN apply false - id(Plugins.KOTLIN_ANDROID) version Versions.KOTLIN apply false - id(Plugins.HILT_ANDROID) version Versions.HILT apply false - id(Plugins.DETEKT) version Versions.DETEKT - id(Plugins.KOVER) version Versions.KOVER + alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.library) apply false + alias(libs.plugins.kotlin.jvm) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.kotlin.kapt) apply false + alias(libs.plugins.kotlin.parcelize) apply false + alias(libs.plugins.hilt) apply false + alias(libs.plugins.detekt) + alias(libs.plugins.kover) } tasks.register("clean", Delete::class) { @@ -14,7 +16,7 @@ tasks.register("clean", Delete::class) { } detekt { - toolVersion = Versions.DETEKT + toolVersion = libs.versions.detekt.get() source = files( "app/src/main/java", diff --git a/template-compose/buildSrc/src/main/java/Dependencies.kt b/template-compose/buildSrc/src/main/java/Dependencies.kt deleted file mode 100644 index 06c295647..000000000 --- a/template-compose/buildSrc/src/main/java/Dependencies.kt +++ /dev/null @@ -1,71 +0,0 @@ -object Dependencies { - object AndroidX { - const val CORE_KTX = "androidx.core:core-ktx:${Versions.CORE_KTX}" - const val LIFECYCLE_RUNTIME_KTX = "androidx.lifecycle:lifecycle-runtime-ktx:${Versions.LIFECYCLE}" - const val LIFECYCLE_RUNTIME_COMPOSE = "androidx.lifecycle:lifecycle-runtime-compose:${Versions.LIFECYCLE}" - - const val DATASTORE_PREFERENCES = "androidx.datastore:datastore-preferences:${Versions.DATASTORE_PREFERENCES}" - const val SECURITY_CRYPTO = "androidx.security:security-crypto:${Versions.SECURITY_CRYPTO}" - } - - object Compose { - const val BOM = "androidx.compose:compose-bom:${Versions.COMPOSE_BOM}" - const val UI = "androidx.compose.ui:ui" - const val UI_TOOLING = "androidx.compose.ui:ui-tooling" - const val UI_TOOLING_PREVIEW = "androidx.compose.ui:ui-tooling-preview" - const val MATERIAL = "androidx.compose.material:material" - const val NAVIGATION = "androidx.navigation:navigation-compose:${Versions.COMPOSE_NAVIGATION}" - - const val ACCOMPANIST_PERMISSIONS = "com.google.accompanist:accompanist-permissions:${Versions.ACCOMPANIST}" - } - - object Hilt { - const val ANDROID = "com.google.dagger:hilt-android:${Versions.HILT}" - const val NAVIGATION_COMPOSE = "androidx.hilt:hilt-navigation-compose:${Versions.HILT_NAVIGATION_COMPOSE}" - const val COMPILER = "com.google.dagger:hilt-compiler:${Versions.HILT}" - - const val JAVAX_INJECT = "javax.inject:javax.inject:${Versions.JAVAX_INJECT}" - } - - object Kotlin { - const val COROUTINES_CORE = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.KOTLIN_COROUTINES}" - } - - object Log { - const val TIMBER = "com.jakewharton.timber:timber:${Versions.TIMBER}" - - const val CHUCKER = "com.github.chuckerteam.chucker:library:${Versions.CHUCKER}" - const val CHUCKER_NO_OP = "com.github.chuckerteam.chucker:library-no-op:${Versions.CHUCKER}" - } - - object Network { - const val RETROFIT = "com.squareup.retrofit2:retrofit:${Versions.RETROFIT}" - const val RETROFIT_CONVERTER_MOSHI = "com.squareup.retrofit2:converter-moshi:${Versions.RETROFIT}" - - const val OKHTTP = "com.squareup.okhttp3:okhttp:${Versions.OKHTTP}" - const val OKHTTP_LOGGING_INTERCEPTOR = "com.squareup.okhttp3:logging-interceptor:${Versions.OKHTTP}" - - const val MOSHI = "com.squareup.moshi:moshi:${Versions.MOSHI}" - const val MOSHI_ADAPTERS = "com.squareup.moshi:moshi-adapters:${Versions.MOSHI}" - const val MOSHI_KOTLIN = "com.squareup.moshi:moshi-kotlin:${Versions.MOSHI}" - } - - object Util { - const val COMMON_KTX = "com.github.nimblehq:android-common-ktx:${Versions.COMMON_KTX}" - } - - object Test { - const val COMPOSE_UI_TEST_JUNIT = "androidx.compose.ui:ui-test-junit4" - const val COROUTINES = "org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.KOTLIN_COROUTINES}" - - const val JUNIT = "junit:junit:${Versions.JUNIT}" - - const val KOTEST = "io.kotest:kotest-assertions-core:${Versions.KOTEST}" - const val MOCKK = "io.mockk:mockk:${Versions.MOCKK}" - - const val ROBOLECTRIC = "org.robolectric:robolectric:${Versions.ROBOLECTRIC}" - - const val TEST_CORE = "androidx.test:core:${Versions.CORE}" - const val TURBINE = "app.cash.turbine:turbine:${Versions.TURBINE}" - } -} diff --git a/template-compose/buildSrc/src/main/java/Plugins.kt b/template-compose/buildSrc/src/main/java/Plugins.kt deleted file mode 100644 index d22a2cf30..000000000 --- a/template-compose/buildSrc/src/main/java/Plugins.kt +++ /dev/null @@ -1,16 +0,0 @@ -object Plugins { - const val ANDROID_APPLICATION = "com.android.application" - const val ANDROID_LIBRARY = "com.android.library" - const val JAVA_LIBRARY = "java-library" - - const val DETEKT = "io.gitlab.arturbosch.detekt" - - const val HILT_ANDROID = "com.google.dagger.hilt.android" - - const val KOTLIN_JVM = "org.jetbrains.kotlin.jvm" - const val KOTLIN_ANDROID = "org.jetbrains.kotlin.android" - const val KOTLIN_KAPT = "kotlin-kapt" - const val KOTLIN_PARCELIZE = "kotlin-parcelize" - - const val KOVER = "org.jetbrains.kotlinx.kover" -} diff --git a/template-compose/buildSrc/src/main/java/Versions.kt b/template-compose/buildSrc/src/main/java/Versions.kt index 04e5458ab..d636de1f1 100644 --- a/template-compose/buildSrc/src/main/java/Versions.kt +++ b/template-compose/buildSrc/src/main/java/Versions.kt @@ -6,44 +6,5 @@ object Versions { const val ANDROID_VERSION_CODE = 1 const val ANDROID_VERSION_NAME = "1.0.0" - const val ACCOMPANIST = "0.30.1" - - const val CHUCKER = "3.5.2" - const val COMMON_KTX = "0.1.1" - const val COMPOSE_BOM = "2023.09.02" const val COMPOSE_COMPILER = "1.5.3" - const val COMPOSE_NAVIGATION = "2.5.3" - const val CORE = "1.4.0" - const val CORE_KTX = "1.10.1" - - const val DATASTORE_PREFERENCES = "1.0.0" - const val DETEKT = "1.21.0" - - const val GRADLE = "8.1.2" - - const val HILT = "2.48" - const val HILT_NAVIGATION_COMPOSE = "1.0.0" - - const val JAVAX_INJECT = "1" - const val JUNIT = "4.13.2" - - const val KOTEST = "5.6.2" - const val KOTLIN = "1.9.10" - const val KOTLIN_COROUTINES = "1.7.1" - const val KOVER = "0.7.3" - - const val LIFECYCLE = "2.6.1" - - const val MOCKK = "1.13.5" - const val MOSHI = "1.12.0" - - const val OKHTTP = "4.11.0" - - const val RETROFIT = "2.9.0" - const val ROBOLECTRIC = "4.10.2" - - const val SECURITY_CRYPTO = "1.0.0" - - const val TIMBER = "4.7.1" - const val TURBINE = "0.13.0" } diff --git a/template-compose/data/build.gradle.kts b/template-compose/data/build.gradle.kts index 417bc2178..46f79c860 100644 --- a/template-compose/data/build.gradle.kts +++ b/template-compose/data/build.gradle.kts @@ -1,7 +1,7 @@ plugins { - id(Plugins.ANDROID_LIBRARY) - id(Plugins.KOTLIN_ANDROID) - id(Plugins.KOVER) + alias(libs.plugins.android.library) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kover) } android { @@ -46,35 +46,19 @@ android { dependencies { implementation(project(Modules.DOMAIN)) - with(Dependencies.AndroidX) { - implementation(CORE_KTX) - implementation(DATASTORE_PREFERENCES) - implementation(SECURITY_CRYPTO) - } - - with(Dependencies.Hilt) { - implementation(JAVAX_INJECT) - } + implementation(libs.androidx.core) + implementation(libs.androidx.datastorePreferences) + implementation(libs.androidx.securityCrypto) - with(Dependencies.Network) { - api(RETROFIT) - api(RETROFIT_CONVERTER_MOSHI) + implementation(libs.javax.inject) - api(OKHTTP) - api(OKHTTP_LOGGING_INTERCEPTOR) + api(libs.bundles.retrofit) + api(libs.bundles.okhttp) + api(libs.moshi) + implementation(libs.bundles.moshi) - api(MOSHI) - implementation(MOSHI_ADAPTERS) - implementation(MOSHI_KOTLIN) - } - - with(Dependencies.Test) { - testImplementation(COROUTINES) - testImplementation(JUNIT) - testImplementation(KOTEST) - testImplementation(MOCKK) - testImplementation(ROBOLECTRIC) - testImplementation(TEST_CORE) - testImplementation(TURBINE) - } + testImplementation(libs.bundles.unitTest) + testImplementation(libs.test.core.ktx) + testImplementation(libs.test.turbine) + testImplementation(libs.test.robolectric) } diff --git a/template-compose/domain/build.gradle.kts b/template-compose/domain/build.gradle.kts index 723baa6fb..5a65d7e2b 100644 --- a/template-compose/domain/build.gradle.kts +++ b/template-compose/domain/build.gradle.kts @@ -1,7 +1,7 @@ plugins { - id(Plugins.JAVA_LIBRARY) - id(Plugins.KOTLIN_JVM) - id(Plugins.KOVER) + id(libs.plugins.javaLibrary.get().pluginId) + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.kover) } java { @@ -10,18 +10,8 @@ java { } dependencies { - with(Dependencies.Kotlin) { - implementation(COROUTINES_CORE) - } + implementation(libs.kotlin.coroutines.core) + implementation(libs.javax.inject) - with(Dependencies.Hilt) { - implementation(JAVAX_INJECT) - } - - with(Dependencies.Test) { - testImplementation(COROUTINES) - testImplementation(JUNIT) - testImplementation(KOTEST) - testImplementation(MOCKK) - } + testImplementation(libs.bundles.unitTest) } diff --git a/template-compose/gradle/libs.versions.toml b/template-compose/gradle/libs.versions.toml new file mode 100644 index 000000000..954e2f74e --- /dev/null +++ b/template-compose/gradle/libs.versions.toml @@ -0,0 +1,143 @@ +[versions] +accompanist = "0.30.1" +chucker = "3.5.2" +composeBom = "2023.09.02" +composeNavigation = "2.5.3" +core = "1.10.1" +datastore = "1.0.0" +detekt = "1.21.0" +gradle = "8.1.2" +hilt = "2.48" +hiltNavigation = "1.0.0" +javaxInject = "1" +kotlinCoroutines = "1.7.1" +nimbleCommon = "0.1.1" +lifecycle = "2.6.1" +security = "1.0.0" +junit = "4.13.2" +kotest = "5.6.2" +kotlin = "1.9.10" +kover = "0.7.3" +mockk = "1.13.5" +moshi = "1.12.0" +okhttp = "4.11.0" +retrofit = "2.9.0" +robolectric = "4.10.2" +timber = "4.7.1" +turbine = "0.13.0" +coreKtx = "1.6.1" + +[libraries] +# AndroidX +androidx-core = { group = "androidx.core", name = "core-ktx", version.ref = "core" } +androidx-lifecycle-runtime = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" } +androidx-lifecycle-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycle" } +androidx-datastorePreferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastore" } +androidx-securityCrypto = { group = "androidx.security", name = "security-crypto", version.ref = "security" } + +# Compose +compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } +compose-ui = { group = "androidx.compose.ui", name = "ui" } +compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } +compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } +compose-material = { group = "androidx.compose.material", name = "material" } +compose-navigation = { group = "androidx.navigation", name = "navigation-compose", version.ref = "composeNavigation" } +accompanist-permissions = { group = "com.google.accompanist", name = "accompanist-permissions", version.ref = "accompanist" } + +# Hilt +hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" } +hilt-navigation = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "hiltNavigation" } +hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt" } +javax-inject = { group = "javax.inject", name = "javax.inject", version.ref = "javaxInject" } + +# Kotlin +kotlin-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinCoroutines" } + +# Log +timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" } +chucker = { group = "com.github.chuckerteam.chucker", name = "library", version.ref = "chucker" } +chucker-no-op = { group = "com.github.chuckerteam.chucker", name = "library-no-op", version.ref = "chucker" } + +# Network +moshi = { group = "com.squareup.moshi", name = "moshi", version.ref = "moshi" } +moshi-adapters = { group = "com.squareup.moshi", name = "moshi-adapters", version.ref = "moshi" } +moshi-kotlin = { group = "com.squareup.moshi", name = "moshi-kotlin", version.ref = "moshi" } +okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" } +okhttp-logging = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp" } +retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" } +retrofit-moshi = { group = "com.squareup.retrofit2", name = "converter-moshi", version.ref = "retrofit" } + +# Util +nimble-common = { group = "com.github.nimblehq", name = "android-common-ktx", version.ref = "nimbleCommon" } + +# Test +test-core-ktx = { group = "androidx.test", name = "core-ktx", version.ref = "coreKtx" } +test-junit = { group = "junit", name = "junit", version.ref = "junit" } +test-kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinCoroutines" } +test-kotest-assertions-core = { group = "io.kotest", name = "kotest-assertions-core", version.ref = "kotest" } +test-mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" } +test-turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" } + +test-compose-ui = { group = "androidx.compose.ui", name = "ui-test-junit4" } +test-robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "robolectric" } + +[bundles] + +androidx = [ + "androidx-core", + "androidx-lifecycle-runtime", + "androidx-lifecycle-compose", + "androidx-datastorePreferences", +] + +compose = [ + "compose-ui", + "compose-ui-tooling-preview", + "compose-material", + "compose-navigation", + "accompanist-permissions", +] + +hilt = [ + "hilt-android", + "hilt-navigation", +] + +retrofit = [ + "retrofit", + "retrofit-moshi", +] + +okhttp = [ + "okhttp", + "okhttp-logging", +] + +moshi = [ + "moshi-adapters", + "moshi-kotlin", +] + +unitTest = [ + "test-kotlinx-coroutines-test", + "test-junit", + "test-kotest-assertions-core", + "test-mockk", +] + +implementationTest = [ + "test-compose-ui", + "test-robolectric", +] + +[plugins] +android-application = { id = "com.android.application", version.ref = "gradle" } +android-library = { id = "com.android.library", version.ref = "gradle" } +detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } +hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } +javaLibrary = { id = "java-library" } +kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } +kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } From 83c2d30ea4a872242c056e93b7aa608d08e71a06 Mon Sep 17 00:00:00 2001 From: Ryan Conway Date: Mon, 6 Jan 2025 10:25:30 +0700 Subject: [PATCH 2/6] [#586] Sort TOML versions alphabetically --- template-compose/gradle/libs.versions.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/template-compose/gradle/libs.versions.toml b/template-compose/gradle/libs.versions.toml index 954e2f74e..d8d8b7ef2 100644 --- a/template-compose/gradle/libs.versions.toml +++ b/template-compose/gradle/libs.versions.toml @@ -4,28 +4,28 @@ chucker = "3.5.2" composeBom = "2023.09.02" composeNavigation = "2.5.3" core = "1.10.1" +coreKtx = "1.6.1" datastore = "1.0.0" detekt = "1.21.0" gradle = "8.1.2" hilt = "2.48" hiltNavigation = "1.0.0" javaxInject = "1" -kotlinCoroutines = "1.7.1" -nimbleCommon = "0.1.1" -lifecycle = "2.6.1" -security = "1.0.0" junit = "4.13.2" kotest = "5.6.2" kotlin = "1.9.10" +kotlinCoroutines = "1.7.1" kover = "0.7.3" +lifecycle = "2.6.1" mockk = "1.13.5" moshi = "1.12.0" +nimbleCommon = "0.1.1" okhttp = "4.11.0" retrofit = "2.9.0" robolectric = "4.10.2" +security = "1.0.0" timber = "4.7.1" turbine = "0.13.0" -coreKtx = "1.6.1" [libraries] # AndroidX From 3913d3f8c685883f9efba93fa0241c2ae4b79448 Mon Sep 17 00:00:00 2001 From: Ryan Conway Date: Mon, 6 Jan 2025 11:06:53 +0700 Subject: [PATCH 3/6] [#586] Move remaining versions to TOML and remove Versions.kt from buildSrc --- template-compose/app/build.gradle.kts | 13 +++++++------ template-compose/buildSrc/src/main/java/Versions.kt | 10 ---------- template-compose/data/build.gradle.kts | 4 ++-- template-compose/gradle/libs.versions.toml | 6 ++++++ 4 files changed, 15 insertions(+), 18 deletions(-) delete mode 100644 template-compose/buildSrc/src/main/java/Versions.kt diff --git a/template-compose/app/build.gradle.kts b/template-compose/app/build.gradle.kts index d97585565..f9a846b11 100644 --- a/template-compose/app/build.gradle.kts +++ b/template-compose/app/build.gradle.kts @@ -14,20 +14,20 @@ val getVersionCode: () -> Int = { if (project.hasProperty("versionCode")) { (project.property("versionCode") as String).toInt() } else { - Versions.ANDROID_VERSION_CODE + libs.versions.androidVersionCode.get().toInt() } } android { namespace = "co.nimblehq.template.compose" - compileSdk = Versions.ANDROID_COMPILE_SDK + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { applicationId = "co.nimblehq.template.compose" - minSdk = Versions.ANDROID_MIN_SDK - targetSdk = Versions.ANDROID_TARGET_SDK + minSdk = libs.versions.androidMinSdk.get().toInt() + targetSdk = libs.versions.androidTargetSdk.get().toInt() versionCode = getVersionCode() - versionName = Versions.ANDROID_VERSION_NAME + versionName = libs.versions.androidVersionName.get() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { @@ -97,8 +97,9 @@ android { buildConfig = true } + // TODO Remove this block in https://github.com/nimblehq/android-templates/issues/587 composeOptions { - kotlinCompilerExtensionVersion = Versions.COMPOSE_COMPILER + kotlinCompilerExtensionVersion = "1.5.3" } packaging { diff --git a/template-compose/buildSrc/src/main/java/Versions.kt b/template-compose/buildSrc/src/main/java/Versions.kt deleted file mode 100644 index d636de1f1..000000000 --- a/template-compose/buildSrc/src/main/java/Versions.kt +++ /dev/null @@ -1,10 +0,0 @@ -object Versions { - const val ANDROID_COMPILE_SDK = 34 - const val ANDROID_MIN_SDK = 24 - const val ANDROID_TARGET_SDK = 34 - - const val ANDROID_VERSION_CODE = 1 - const val ANDROID_VERSION_NAME = "1.0.0" - - const val COMPOSE_COMPILER = "1.5.3" -} diff --git a/template-compose/data/build.gradle.kts b/template-compose/data/build.gradle.kts index 46f79c860..25546161c 100644 --- a/template-compose/data/build.gradle.kts +++ b/template-compose/data/build.gradle.kts @@ -6,10 +6,10 @@ plugins { android { namespace = "co.nimblehq.template.compose.data" - compileSdk = Versions.ANDROID_COMPILE_SDK + compileSdk = libs.versions.androidCompileSdk.get().toInt() defaultConfig { - minSdk = Versions.ANDROID_MIN_SDK + minSdk = libs.versions.androidMinSdk.get().toInt() consumerProguardFiles("consumer-rules.pro") } diff --git a/template-compose/gradle/libs.versions.toml b/template-compose/gradle/libs.versions.toml index d8d8b7ef2..d5762a9c9 100644 --- a/template-compose/gradle/libs.versions.toml +++ b/template-compose/gradle/libs.versions.toml @@ -1,4 +1,10 @@ [versions] +androidCompileSdk = "35" +androidMinSdk = "24" +androidTargetSdk = "35" +androidVersionCode = "1" +androidVersionName = "0.37.0" + accompanist = "0.30.1" chucker = "3.5.2" composeBom = "2023.09.02" From 6a32b15eb28223d5a417247fb347b4f2df7a8b17 Mon Sep 17 00:00:00 2001 From: Ryan Conway Date: Wed, 8 Jan 2025 17:18:01 +0700 Subject: [PATCH 4/6] [#586] Revert compileSdk and versionName changes --- template-compose/gradle/libs.versions.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/template-compose/gradle/libs.versions.toml b/template-compose/gradle/libs.versions.toml index d5762a9c9..4dc0ef6df 100644 --- a/template-compose/gradle/libs.versions.toml +++ b/template-compose/gradle/libs.versions.toml @@ -1,9 +1,9 @@ [versions] -androidCompileSdk = "35" +androidCompileSdk = "34" androidMinSdk = "24" -androidTargetSdk = "35" +androidTargetSdk = "34" androidVersionCode = "1" -androidVersionName = "0.37.0" +androidVersionName = "1.0.0" accompanist = "0.30.1" chucker = "3.5.2" From 645f7811fd48cb402741088bdc17bca8eccfe2cf Mon Sep 17 00:00:00 2001 From: Ryan Conway Date: Wed, 8 Jan 2025 17:42:34 +0700 Subject: [PATCH 5/6] [#586] Clean up TOML --- template-compose/app/build.gradle.kts | 9 +++++-- template-compose/data/build.gradle.kts | 4 +-- template-compose/domain/build.gradle.kts | 2 +- template-compose/gradle/libs.versions.toml | 29 +++++++--------------- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/template-compose/app/build.gradle.kts b/template-compose/app/build.gradle.kts index f9a846b11..0b7fedfd7 100644 --- a/template-compose/app/build.gradle.kts +++ b/template-compose/app/build.gradle.kts @@ -135,9 +135,11 @@ dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) implementation(libs.bundles.androidx) + implementation(libs.androidx.datastore.preferences) implementation(platform(libs.compose.bom)) implementation(libs.bundles.compose) + implementation(libs.accompanist.permissions) debugImplementation(libs.compose.ui.tooling) implementation(libs.bundles.hilt) @@ -145,14 +147,17 @@ dependencies { implementation(libs.timber) debugImplementation(libs.chucker) - releaseImplementation(libs.chucker.no.op) + releaseImplementation(libs.chucker.noOp) implementation(libs.nimble.common) + // Unit test testImplementation(libs.bundles.unitTest) testImplementation(libs.test.turbine) + + // UI test with Robolectric testImplementation(platform(libs.compose.bom)) - testImplementation(libs.bundles.implementationTest) + testImplementation(libs.bundles.uiTest) } /* diff --git a/template-compose/data/build.gradle.kts b/template-compose/data/build.gradle.kts index 25546161c..0babc9a87 100644 --- a/template-compose/data/build.gradle.kts +++ b/template-compose/data/build.gradle.kts @@ -47,8 +47,8 @@ dependencies { implementation(project(Modules.DOMAIN)) implementation(libs.androidx.core) - implementation(libs.androidx.datastorePreferences) - implementation(libs.androidx.securityCrypto) + implementation(libs.androidx.datastore.preferences) + implementation(libs.androidx.security.crypto) implementation(libs.javax.inject) diff --git a/template-compose/domain/build.gradle.kts b/template-compose/domain/build.gradle.kts index 5a65d7e2b..4206bdce5 100644 --- a/template-compose/domain/build.gradle.kts +++ b/template-compose/domain/build.gradle.kts @@ -10,7 +10,7 @@ java { } dependencies { - implementation(libs.kotlin.coroutines.core) + implementation(libs.kotlinx.coroutines.core) implementation(libs.javax.inject) testImplementation(libs.bundles.unitTest) diff --git a/template-compose/gradle/libs.versions.toml b/template-compose/gradle/libs.versions.toml index 4dc0ef6df..efe7cadc9 100644 --- a/template-compose/gradle/libs.versions.toml +++ b/template-compose/gradle/libs.versions.toml @@ -10,7 +10,6 @@ chucker = "3.5.2" composeBom = "2023.09.02" composeNavigation = "2.5.3" core = "1.10.1" -coreKtx = "1.6.1" datastore = "1.0.0" detekt = "1.21.0" gradle = "8.1.2" @@ -20,7 +19,7 @@ javaxInject = "1" junit = "4.13.2" kotest = "5.6.2" kotlin = "1.9.10" -kotlinCoroutines = "1.7.1" +kotlinxCoroutines = "1.7.1" kover = "0.7.3" lifecycle = "2.6.1" mockk = "1.13.5" @@ -30,6 +29,7 @@ okhttp = "4.11.0" retrofit = "2.9.0" robolectric = "4.10.2" security = "1.0.0" +testCore = "1.6.1" timber = "4.7.1" turbine = "0.13.0" @@ -38,8 +38,8 @@ turbine = "0.13.0" androidx-core = { group = "androidx.core", name = "core-ktx", version.ref = "core" } androidx-lifecycle-runtime = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" } androidx-lifecycle-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycle" } -androidx-datastorePreferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastore" } -androidx-securityCrypto = { group = "androidx.security", name = "security-crypto", version.ref = "security" } +androidx-datastore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastore" } +androidx-security-crypto = { group = "androidx.security", name = "security-crypto", version.ref = "security" } # Compose compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } @@ -57,12 +57,12 @@ hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.r javax-inject = { group = "javax.inject", name = "javax.inject", version.ref = "javaxInject" } # Kotlin -kotlin-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinCoroutines" } +kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" } # Log timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" } chucker = { group = "com.github.chuckerteam.chucker", name = "library", version.ref = "chucker" } -chucker-no-op = { group = "com.github.chuckerteam.chucker", name = "library-no-op", version.ref = "chucker" } +chucker-noOp = { group = "com.github.chuckerteam.chucker", name = "library-no-op", version.ref = "chucker" } # Network moshi = { group = "com.squareup.moshi", name = "moshi", version.ref = "moshi" } @@ -77,61 +77,50 @@ retrofit-moshi = { group = "com.squareup.retrofit2", name = "converter-moshi", v nimble-common = { group = "com.github.nimblehq", name = "android-common-ktx", version.ref = "nimbleCommon" } # Test -test-core-ktx = { group = "androidx.test", name = "core-ktx", version.ref = "coreKtx" } +test-core-ktx = { group = "androidx.test", name = "core-ktx", version.ref = "testCore" } test-junit = { group = "junit", name = "junit", version.ref = "junit" } -test-kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinCoroutines" } +test-kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" } test-kotest-assertions-core = { group = "io.kotest", name = "kotest-assertions-core", version.ref = "kotest" } test-mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" } test-turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" } - test-compose-ui = { group = "androidx.compose.ui", name = "ui-test-junit4" } test-robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "robolectric" } [bundles] - androidx = [ "androidx-core", "androidx-lifecycle-runtime", "androidx-lifecycle-compose", - "androidx-datastorePreferences", ] - compose = [ "compose-ui", "compose-ui-tooling-preview", "compose-material", "compose-navigation", - "accompanist-permissions", ] - hilt = [ "hilt-android", "hilt-navigation", ] - retrofit = [ "retrofit", "retrofit-moshi", ] - okhttp = [ "okhttp", "okhttp-logging", ] - moshi = [ "moshi-adapters", "moshi-kotlin", ] - unitTest = [ "test-kotlinx-coroutines-test", "test-junit", "test-kotest-assertions-core", "test-mockk", ] - -implementationTest = [ +uiTest = [ "test-compose-ui", "test-robolectric", ] From 8cca2904f6ed81b75048156ec946d285fbf60ce0 Mon Sep 17 00:00:00 2001 From: Ryan Conway Date: Mon, 6 Jan 2025 11:06:53 +0700 Subject: [PATCH 6/6] [#586] Enable typesafe project accessors and remove Modules.kt --- template-compose/app/build.gradle.kts | 8 ++++---- template-compose/buildSrc/src/main/java/Modules.kt | 4 ---- template-compose/data/build.gradle.kts | 2 +- template-compose/settings.gradle.kts | 3 ++- 4 files changed, 7 insertions(+), 10 deletions(-) delete mode 100644 template-compose/buildSrc/src/main/java/Modules.kt diff --git a/template-compose/app/build.gradle.kts b/template-compose/app/build.gradle.kts index 0b7fedfd7..2f5858be9 100644 --- a/template-compose/app/build.gradle.kts +++ b/template-compose/app/build.gradle.kts @@ -129,8 +129,8 @@ kapt { } dependencies { - implementation(project(Modules.DATA)) - implementation(project(Modules.DOMAIN)) + implementation(projects.data) + implementation(projects.domain) implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) @@ -164,8 +164,8 @@ dependencies { * Kover configs */ dependencies { - kover(project(Modules.DATA)) - kover(project(Modules.DOMAIN)) + kover(projects.data) + kover(projects.domain) } koverReport { diff --git a/template-compose/buildSrc/src/main/java/Modules.kt b/template-compose/buildSrc/src/main/java/Modules.kt deleted file mode 100644 index cc4fbdc5a..000000000 --- a/template-compose/buildSrc/src/main/java/Modules.kt +++ /dev/null @@ -1,4 +0,0 @@ -object Modules { - const val DATA = ":data" - const val DOMAIN = ":domain" -} diff --git a/template-compose/data/build.gradle.kts b/template-compose/data/build.gradle.kts index 0babc9a87..10556fed4 100644 --- a/template-compose/data/build.gradle.kts +++ b/template-compose/data/build.gradle.kts @@ -44,7 +44,7 @@ android { } dependencies { - implementation(project(Modules.DOMAIN)) + implementation(projects.domain) implementation(libs.androidx.core) implementation(libs.androidx.datastore.preferences) diff --git a/template-compose/settings.gradle.kts b/template-compose/settings.gradle.kts index e182ae88a..cfd2b7aad 100644 --- a/template-compose/settings.gradle.kts +++ b/template-compose/settings.gradle.kts @@ -14,7 +14,8 @@ dependencyResolutionManagement { } } -rootProject.name = "Template Compose" +rootProject.name = "TemplateCompose" +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") include(":app") include(":data") include(":domain")