Refactor: Use Gradle version catalog

This commit introduces the Gradle version catalog (`libs.versions.toml`) to manage dependencies and plugin versions centrally.

Key changes:
- Added `gradle/libs.versions.toml` defining versions, libraries, plugins, and bundles.
- Updated `app/build.gradle.kts` to reference dependencies and plugins from the version catalog.
- Updated project-level `build.gradle.kts` to use plugin aliases from the version catalog.
This commit is contained in:
prudhvir3ddy
2025-07-10 17:42:23 +05:30
parent 28de0d3570
commit 07d0f1089f
3 changed files with 168 additions and 40 deletions
+137
View File
@@ -0,0 +1,137 @@
[versions]
# Android and Kotlin
agp = "8.2.0"
kotlin = "1.9.20"
compileSdk = "34"
minSdk = "26" # API 26 for proper BLE support
targetSdk = "34"
# AndroidX Core
core-ktx = "1.12.0"
lifecycle-runtime = "2.7.0"
activity-compose = "1.8.2"
appcompat = "1.6.1"
# Compose
compose-bom = "2023.10.01"
compose-compiler = "1.5.5"
# Navigation
navigation-compose = "2.7.6"
# Accompanist
accompanist-permissions = "0.32.0"
# Cryptography
bouncycastle = "1.70"
tink-android = "1.10.0"
# JSON
gson = "2.10.1"
# Coroutines
kotlinx-coroutines = "1.7.3"
# Bluetooth
nordic-ble = "2.6.1"
# Compression
lz4-java = "1.8.0"
# Security
security-crypto = "1.1.0-alpha06"
# Testing
junit = "4.13.2"
androidx-test-ext = "1.1.5"
espresso = "3.5.1"
[libraries]
# AndroidX Core
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle-runtime" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
# Compose
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
androidx-compose-runtime = { group = "androidx.compose.runtime", name = "runtime" }
androidx-compose-runtime-livedata = { group = "androidx.compose.runtime", name = "runtime-livedata" }
# Lifecycle
androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycle-runtime" }
androidx-lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "lifecycle-runtime" }
# Navigation
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigation-compose" }
# Accompanist
accompanist-permissions = { group = "com.google.accompanist", name = "accompanist-permissions", version.ref = "accompanist-permissions" }
# Cryptography
bouncycastle-bcprov = { group = "org.bouncycastle", name = "bcprov-jdk15on", version.ref = "bouncycastle" }
google-tink-android = { group = "com.google.crypto.tink", name = "tink-android", version.ref = "tink-android" }
# JSON
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
# Coroutines
kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
# Bluetooth
nordic-ble = { group = "no.nordicsemi.android", name = "ble", version.ref = "nordic-ble" }
# Compression
lz4-java = { group = "org.lz4", name = "lz4-java", version.ref = "lz4-java" }
# Security
androidx-security-crypto = { group = "androidx.security", name = "security-crypto", version.ref = "security-crypto" }
# Testing
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext" }
androidx-test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso" }
androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-parcelize = { id = "kotlin-parcelize" }
[bundles]
compose = [
"androidx-compose-ui",
"androidx-compose-ui-graphics",
"androidx-compose-ui-tooling-preview",
"androidx-compose-material3",
"androidx-compose-runtime-livedata"
]
lifecycle = [
"androidx-lifecycle-runtime-ktx",
"androidx-lifecycle-viewmodel-compose",
"androidx-lifecycle-livedata-ktx"
]
cryptography = [
"bouncycastle-bcprov",
"google-tink-android"
]
testing = [
"junit",
"androidx-test-ext-junit",
"androidx-test-espresso-core"
]
compose-testing = [
"androidx-compose-ui-test-junit4",
"androidx-compose-ui-test-manifest"
]