gradle version catalog migration
This commit is contained in:
@@ -21,3 +21,4 @@
|
||||
{"type":"discussion","id":"DSC-0020","status":"done","ticket":"studio-editor-indentation-policy-and-project-setup","title":"Indentation Policy, Status-Bar Semantics, and Project-Local Editor Setup","created_at":"2026-04-04","updated_at":"2026-04-04","tags":["studio","editor","indentation","tabs","setup","dot-studio","configuration","ux"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0033","file":"discussion/lessons/DSC-0020-studio-editor-indentation-policy-and-project-setup/LSN-0033-setup-owned-indentation-policy-and-project-bootstrap-defaults.md","status":"done","created_at":"2026-04-04","updated_at":"2026-04-04"}]}
|
||||
{"type":"discussion","id":"DSC-0021","status":"done","ticket":"studio-frontend-editor-write-and-save-wave","title":"Enable Frontend Editing and Save in the Studio Code Editor","created_at":"2026-04-04","updated_at":"2026-04-06","tags":["studio","editor","frontend","write","save","vfs","lsp","pbs","access-policy"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0036","file":"discussion/lessons/DSC-0021-studio-frontend-editor-write-and-save-wave/LSN-0036-vfs-owned-frontend-edit-and-save-wave.md","status":"done","created_at":"2026-04-06","updated_at":"2026-04-06"}]}
|
||||
{"type":"discussion","id":"DSC-0022","status":"done","ticket":"studio-play-stop-cartridge-flow","title":"Wire the Studio Play/Stop button to shipper phase 1 cartridge preparation and runtime execution","created_at":"2026-04-06","updated_at":"2026-04-07","tags":["studio","play-stop","shipper","runtime","cartridge","shell"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0022","file":"discussion/lessons/DSC-0022-studio-play-stop-and-debugger-integration/LSN-0022-studio-play-stop-and-debugger-integration.md","status":"done","created_at":"2026-04-07","updated_at":"2026-04-07"}]}
|
||||
{"type":"discussion","id":"DSC-0023","status":"done","ticket":"gradle-version-catalog-migration","title":"Move dependency version management to Version Catalog (TOML)","created_at":"2026-04-07","updated_at":"2026-04-07","tags":["gradle","buildSrc","dependency-management","version-catalog"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0037","file":"discussion/lessons/DSC-0023-gradle-version-catalog-migration/LSN-0037-gradle-version-catalog-adoption.md","status":"done","created_at":"2026-04-07","updated_at":"2026-04-07"}]}
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
# LSN-0037: Gradle Version Catalog for Dependency Management
|
||||
|
||||
## Original Problem
|
||||
Dependency versions were scattered across the project, including hardcoded strings in `buildSrc` conventions and `build.gradle.kts` files. This fragmentation made maintenance difficult and prevented a clear overview of external dependencies.
|
||||
|
||||
## Consolidated Decision
|
||||
Adopt `gradle/libs.versions.toml` (Version Catalog) as the single source of truth for all external dependencies and versions in the `prometeu-studio` repository.
|
||||
|
||||
## Final Implementation
|
||||
1. **Version Catalog Definition**: Centralized all external libraries in `gradle/libs.versions.toml` under the `[versions]` and `[libraries]` sections.
|
||||
2. **buildSrc Access**: Configured `buildSrc` to consume the same catalog by using the `VersionCatalogsExtension` in the `gradle.java-common-conventions.gradle.kts` file.
|
||||
3. **Convention Refactoring**: Updated Java common conventions to use `libs.findLibrary(...).get()` for resolving dependencies from the catalog.
|
||||
|
||||
### Example: Using Catalog in buildSrc (Kotlin DSL)
|
||||
Since `buildSrc` is a separate build, the type-safe accessors (like `libs.lombok`) are not automatically generated in the same way as in the main project modules. We use the following pattern:
|
||||
|
||||
```kotlin
|
||||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
|
||||
|
||||
dependencies {
|
||||
implementation(libs.findLibrary("lombok").get())
|
||||
}
|
||||
```
|
||||
|
||||
## Examples and Usage
|
||||
In standard modules (`build.gradle.kts`), use the type-safe accessors provided by Gradle:
|
||||
|
||||
```kotlin
|
||||
dependencies {
|
||||
implementation(libs.javafx.controls)
|
||||
}
|
||||
```
|
||||
|
||||
## Common Pitfalls
|
||||
- **buildSrc Visibility**: Direct access like `libs.libraryName` might fail in `buildSrc` if the catalog isn't properly shared or if the accessor isn't generated for the `buildSrc` context. Using `VersionCatalogsExtension` is the most robust way to share it.
|
||||
- **Naming Consistency**: Ensure library aliases in TOML follow a clear pattern (e.g., `slf4j-api` vs `slf4jApi`) to keep the build scripts readable.
|
||||
|
||||
## References
|
||||
- [DEC-0023-gradle-version-catalog-adoption.md](../../workflow/decisions/DEC-0023-gradle-version-catalog-adoption.md)
|
||||
- [PLN-0046-implement-gradle-version-catalog.md](../../workflow/plans/PLN-0046-implement-gradle-version-catalog.md)
|
||||
Reference in New Issue
Block a user