android / android/nowinandroid

[FR]: Use gradle version catalog's type-safe accessors in `build-logic`

Open
#317 1 comment 2 reactions 0 assignees View on GitHub
enhancement waiting
Dominant language
Kotlin
Stars
21.8k
Forks
4.6k
Avg merge
19h 20m
Merged PRs (30d)
2

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the problem

Currently, `build-logic` uses the gradle version catalog without type-safe accessors and the names of libraries and plugins are hard-coded.

For example, the `AndroidFeatureConventionPlugin` has the following code snippet:

```kt
dependencies {
add("implementation", libs.findLibrary("androidx.hilt.navigation.compose").get())
add("implementation", libs.findLibrary("androidx.lifecycle.runtimeCompose").get())
add("implementation", libs.findLibrary("androidx.lifecycle.viewModelCompose").get())
}
```

### Describe the solution

With the gradle version catalog's type-safe accessors, the above code snippet can be replaced with:

```kt
dependencies {
add("implementation", libs.androidx.hilt.navigation.compose)
add("implementation", libs.androidx.lifecycle.runtimeCompose)
add("implementation", libs.androidx.lifecycle.viewModelCompose)
}
```

### Additional context

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

Start in build-logic by locating AndroidFeatureConventionPlugin and inspect how its version catalog dependencies are accessed. Review the other build-logic convention plugins for the same hard-coded library and plugin names, then verify that the affected references use type-safe accessors and the build still succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
build-system
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.