ground-android icon indicating copy to clipboard operation
ground-android copied to clipboard

[Code health] Introduce Version Catalog for Dependency Management

Open anandwana001 opened this issue 1 year ago • 0 comments

Introduction of a version catalog to streamline and centralize dependency management across the project.

Motivation

Currently, dependencies and their versions are scattered throughout the project's build files. This approach makes it difficult to maintain consistency and update dependencies efficiently. By introducing a version catalog, we can:

  • Centralize dependency versions in one location.
  • Simplify updates to dependencies across multiple modules.
  • Improve readability and maintainability of build scripts.

Gradle’s version catalog feature allows us to define all our dependencies and their versions in a single libs.versions.toml file. This file would live in the gradle directory and would include:

  • Libraries: Define common libraries and their versions.
  • Plugins: Centralize plugin versions.
  • Bundles: Group related libraries together for easy inclusion in modules.

Example

[libraries]
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }

[versions]
kotlin = "1.8.0"
coroutines = "1.6.0"

Impact

  • Backward Compatibility: There should be minimal impact on backward compatibility as existing dependencies can be gradually migrated to use the catalog.

  • Build Script Changes: Developers will need to adapt to the new way of declaring dependencies, but the benefits in maintainability outweigh the initial learning curve.

Reference

https://developer.android.com/build/migrate-to-catalogs

anandwana001 avatar Aug 14 '24 01:08 anandwana001