gradle version catalog migration
This commit is contained in:
parent
88bf9fbd45
commit
246d5258aa
@ -6,20 +6,24 @@ repositories {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
constraints {
|
constraints {
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOnly("org.projectlombok:lombok:1.18.32")
|
implementation(libs.findLibrary("jacoco-core").get())
|
||||||
annotationProcessor("org.projectlombok:lombok:1.18.32")
|
|
||||||
testCompileOnly("org.projectlombok:lombok:1.18.32")
|
|
||||||
testAnnotationProcessor("org.projectlombok:lombok:1.18.32")
|
|
||||||
|
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter:5.12.1")
|
compileOnly(libs.findLibrary("lombok").get())
|
||||||
|
annotationProcessor(libs.findLibrary("lombok").get())
|
||||||
|
testCompileOnly(libs.findLibrary("lombok").get())
|
||||||
|
testAnnotationProcessor(libs.findLibrary("lombok").get())
|
||||||
|
|
||||||
|
testImplementation(libs.findLibrary("junit-jupiter").get())
|
||||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||||
|
|
||||||
implementation("org.slf4j:slf4j-api:2.0.7")
|
implementation(libs.findLibrary("slf4j-api").get())
|
||||||
implementation("org.slf4j:slf4j-simple:2.0.7")
|
implementation(libs.findLibrary("slf4j-simple").get())
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
|||||||
@ -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-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-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-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"}]}
|
||||||
|
|||||||
@ -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)
|
||||||
@ -2,6 +2,10 @@
|
|||||||
javafx = "23.0.2"
|
javafx = "23.0.2"
|
||||||
richtextfx = "0.11.2"
|
richtextfx = "0.11.2"
|
||||||
jackson = "2.18.2"
|
jackson = "2.18.2"
|
||||||
|
jacoco = "0.8.12"
|
||||||
|
lombok = "1.18.32"
|
||||||
|
junit-jupiter = "5.12.1"
|
||||||
|
slf4j = "2.0.7"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
javafx-controls = { group = "org.openjfx", name = "javafx-controls", version.ref = "javafx" }
|
javafx-controls = { group = "org.openjfx", name = "javafx-controls", version.ref = "javafx" }
|
||||||
@ -11,6 +15,11 @@ jackson-databind = { group = "com.fasterxml.jackson.core", name = "jackson-datab
|
|||||||
apache-commons-lang3 = { group = "org.apache.commons", name = "commons-lang3", version = "3.18.0" }
|
apache-commons-lang3 = { group = "org.apache.commons", name = "commons-lang3", version = "3.18.0" }
|
||||||
apache-commons-io = { group = "commons-io", name = "commons-io", version = "2.13.0" }
|
apache-commons-io = { group = "commons-io", name = "commons-io", version = "2.13.0" }
|
||||||
apache-commons-collections = { group = "org.apache.commons", name = "commons-collections4", version = "4.4" }
|
apache-commons-collections = { group = "org.apache.commons", name = "commons-collections4", version = "4.4" }
|
||||||
|
jacoco-core = { group = "org.jacoco", name = "org.jacoco.core", version.ref = "jacoco" }
|
||||||
|
lombok = { group = "org.projectlombok", name = "lombok", version.ref = "lombok" }
|
||||||
|
junit-jupiter = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit-jupiter" }
|
||||||
|
slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" }
|
||||||
|
slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version.ref = "slf4j" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
javafx = { id = "org.openjfx.javafxplugin", version = "0.1.0" }
|
javafx = { id = "org.openjfx.javafxplugin", version = "0.1.0" }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user