feat: Introduce Version Catalog for Dependency Management (#1607)

* feat: Introduce Version Catalog for Dependency Management

This commit introduces a version catalog via `libs.versions.toml` to centralize and manage project dependencies. It replaces the previous hardcoded dependency versions in `app/build.gradle` with references to the version catalog. This change enhances maintainability and organization by centralizing dependency management.

- Added `gradle/libs.versions.toml` to define dependencies and their versions.
- Updated `app/build.gradle` to utilize dependencies from the version catalog.

* chore: migrate plugins to version catalog

* chore: sort lines in `libs.versions.toml`

-Sorts `versions`, `dependencies`, and `plugins` references alphabetically.

* feat: pin ZXing Core dependency

*   Suppressed warning about updating zxing-core to avoid confusion.
*   Added a note to avoid updating zxing-core.

* refactor: Enforce consistent `implementation()` calls in `build.gradle`

-   Ensures all library dependencies are called with `implementation(libs.xxx)` instead of `implementation libs.xxx` in `build.gradle`.

* feat: use version catalog bundles

- Updated dependencies in the app build.gradle to use bundles where possible.

* fix: fix ui test dependency declarations

* chore: comments for clarity

* fix: remove material3 from this PR
This commit is contained in:
James Rich 2025-02-24 18:42:37 -06:00 committed by GitHub
parent 1e9b1c2bc3
commit 4242afef9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 238 additions and 141 deletions

View file

@ -1,13 +1,13 @@
plugins {
id 'com.android.application'
id "org.jetbrains.kotlin.android"
id "org.jetbrains.kotlin.plugin.compose"
id "org.jetbrains.kotlin.plugin.parcelize"
id 'kotlinx-serialization'
id 'com.google.dagger.hilt.android'
id 'com.google.protobuf'
id "com.google.devtools.ksp"
id "io.gitlab.arturbosch.detekt" version "1.23.8"
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.compose)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.hilt)
alias(libs.plugins.protobuf)
alias(libs.plugins.devtools.ksp)
alias(libs.plugins.detekt)
}
def keystorePropertiesFile = rootProject.file("keystore.properties")
@ -110,7 +110,7 @@ android {
// per protobuf-gradle-plugin docs, this is recommended for android
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:$protobuf_version"
artifact = libs.protobuf.protoc.get()
}
generateProtoTasks {
all().each { task ->
@ -141,133 +141,63 @@ androidComponents {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
def appcompat_version = '1.7.0'
implementation "androidx.appcompat:appcompat:$appcompat_version"
// For loading and tinting drawables on older versions of the platform
implementation "androidx.appcompat:appcompat-resources:$appcompat_version"
implementation "androidx.emoji2:emoji2-emojipicker:1.5.0"
implementation(fileTree(dir: 'libs', include: ['*.jar']))
implementation 'androidx.core:core-ktx:1.15.0'
implementation 'androidx.core:core-location-altitude:1.0.0-alpha03'
implementation 'androidx.fragment:fragment-ktx:1.8.6'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.viewpager2:viewpager2:1.1.0'
implementation 'androidx.datastore:datastore:1.1.2'
// Bundles
implementation(libs.bundles.androidx)
implementation(libs.bundles.ui)
debugImplementation(libs.bundles.ui.tooling)
implementation(libs.bundles.lifecycle)
implementation(libs.bundles.navigation)
implementation(libs.bundles.coroutines)
implementation(libs.bundles.datastore)
implementation(libs.bundles.room)
implementation(libs.bundles.hilt)
implementation(libs.bundles.protobuf)
// Lifecycle
def lifecycle_version = '2.8.7'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-runtime-compose:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"
//OSM
implementation(libs.bundles.osm)
implementation(libs.osmdroid.geopackage){ exclude group: "com.j256.ormlite" }
// Room
def room_version = '2.6.1'
implementation "androidx.room:room-runtime:$room_version"
ksp "androidx.room:room-compiler:$room_version"
// optional - Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:$room_version"
// optional - Test helpers
androidTestImplementation "androidx.room:room-testing:$room_version"
//ZXing
implementation(libs.zxing.android.embedded) { transitive = false }
implementation(libs.zxing.core) // do not update
// Hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
implementation "androidx.hilt:hilt-navigation-compose:1.2.0"
ksp "com.google.dagger:hilt-compiler:$hilt_version"
androidTestImplementation "com.google.dagger:hilt-android-testing:$hilt_version"
kspAndroidTest "com.google.dagger:hilt-compiler:$hilt_version"
//Individual dependencies
implementation(libs.appintro)
implementation(libs.awesome.app.rating)
implementation(libs.core.splashscreen)
implementation(libs.emoji2.emojipicker)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.kotlinx.serialization.json)
implementation(libs.org.eclipse.paho.client.mqttv3)
implementation(libs.streamsupport.minifuture)
implementation(libs.usb.serial.android)
implementation(libs.work.runtime.ktx)
implementation(libs.core.location.altitude)
// Navigation
def nav_version = "2.8.7"
implementation "androidx.navigation:navigation-compose:$nav_version"
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
//Compose BOM
implementation(platform(libs.compose.bom))
androidTestImplementation(platform(libs.compose.bom))
// Compose
def composeBom = platform('androidx.compose:compose-bom:2025.02.00')
implementation composeBom
androidTestImplementation composeBom
//Firebase BOM
googleImplementation(platform(libs.firebase.bom)) //For Firebase
googleImplementation(libs.bundles.firebase)
implementation 'androidx.compose.material:material'
implementation 'androidx.compose.material:material-icons-extended'
implementation 'androidx.activity:activity-compose'
implementation 'androidx.compose.runtime:runtime-livedata'
//ksp
ksp(libs.room.compiler)
ksp(libs.hilt.compiler)
kspAndroidTest(libs.hilt.compiler)
// Immutable Collections (for Compose UI State)
implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.8")
//Testing
testImplementation(libs.bundles.testing)
debugImplementation(libs.bundles.testing.android.manifest)
androidTestImplementation(libs.bundles.testing.android)
androidTestImplementation(libs.bundles.testing.hilt)
androidTestImplementation(libs.bundles.testing.navigation)
androidTestImplementation(libs.bundles.testing.room)
// Android Studio Preview support
implementation 'androidx.compose.ui:ui-tooling-preview'
debugImplementation 'androidx.compose.ui:ui-tooling'
// UI Tests
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
// Osmdroid & Maps
def osmdroid_version = '6.1.14'
implementation "org.osmdroid:osmdroid-android:$osmdroid_version"
implementation "org.osmdroid:osmdroid-wms:$osmdroid_version"
implementation("org.osmdroid:osmdroid-geopackage:$osmdroid_version") {
exclude group: 'com.j256.ormlite'
}
implementation 'com.github.MKergall:osmbonuspack:6.9.0'
implementation "mil.nga:mgrs:2.1.3"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
// kotlin serialization
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0"
// rate this app
googleImplementation 'com.suddenh4x.ratingdialog:awesome-app-rating:2.8.0'
// Coroutines
def coroutines_version = '1.10.1'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-guava:$coroutines_version"
// For now I'm not using javalite, because I want JSON printing
implementation "com.google.protobuf:protobuf-kotlin:$protobuf_version"
// For UART access
implementation 'com.github.mik3y:usb-serial-for-android:3.8.1'
// For Firebase Crashlytics & Analytics
googleImplementation platform('com.google.firebase:firebase-bom:33.9.0')
googleImplementation 'com.google.firebase:firebase-crashlytics'
googleImplementation 'com.google.firebase:firebase-analytics'
// barcode support
// per https://github.com/journeyapps/zxing-android-embedded#older-sdk-versions for minSdkVersion 21
implementation('com.journeyapps:zxing-android-embedded:4.3.0') { transitive = false }
//noinspection GradleDependency
implementation 'com.google.zxing:core:3.3.0' // <-- don't update
def work_version = '2.10.0'
// Work Request - used to delay boot event handling
implementation "androidx.work:work-runtime-ktx:$work_version"
implementation "androidx.core:core-splashscreen:1.0.1"
// CompletableFuture backport for API 14+
implementation 'net.sourceforge.streamsupport:streamsupport-minifuture:1.7.4'
// App intro
implementation 'com.github.AppIntro:AppIntro:6.3.1'
// MQTT
implementation "org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5"
// detekt ktlint formatting
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.8")
detektPlugins(libs.detekt.formatting)
}
ksp {