Use TOML Versions Catalogs instead of dependencies.gradle.kts #13790
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contributor checklist
Fixes #1234
syntaxBackground
Currently, the project uses a monolithic
dependencies.gradle.kts
to specify dependency versions. This is not so bad, and the libraries are nicely split up into separate catalogs. (Tasteful!)However, there is no IDE integration when specifying dependencies this way, so you see this in Android Studio:
This means you miss out on visual queues about out-of-date dependencies, etc.
As of Gradle 7.0, Gradle has been endorsing a different way of specifying dependencies, by using
.toml
version catalog files. These have good IDE integration, so you can see guidance around out-of-date dependencies and even get suggestions under the Project Settings:Approach
To make sure I faithfully copied each dependency over to the new file format, I wrote a sloppy Python script that parsed each line with some regexes and then spit out the new format.
After I did this, resolved miscellaneous issues, and validated
./gradlew qa
still passes, I remove dependencies that were not being referenced anywhere (these are easy to spot now because the IDE tells you about them).Testing
While I was going about this, I wanted to ensure two things were true:
.toml
files:a.
libs.versions.toml
b.
test-libs.versions.toml
c.
lint-libs.versions.toml
d.
benchmark-libs.versions.toml
(1) was not initially true; I had to manually register the non-
libs
toml files in the projects' twosettings.gradle.kts
. But, after doing that, I was able to build the project without updating any other Gradle build files that make references to the existing catalogs.To validate (2), I tried updating a dependency from the IDE auto-suggestions and then running
./gradlew qa
. It fails as intended: