Address Gradle 9.6 deprecations in build logic#725
Conversation
Gradle 9.6 deprecates the Kotlin DSL delegated-property accessors (`by registering`, `by getting`, and the `PropertyDelegate` interface), all scheduled for removal in Gradle 10. Replace them with the string-based lazy APIs: - `jvm-module`, `write-manifest`: `tasks.register(...)` instead of `by registering`. - `kmp-module`: `getByName(...)` for KMP source sets instead of `by getting`, dropping the now-redundant `@Suppress` annotations. - `jacoco-kotlin-jvm`, `jacoco-kmm-jvm`, `uber-jar-module`: `tasks.named(...)` instead of the eager `by tasks.getting`, dropping the suppressed unused `val`s that existed only for the delegate side effect. - `ProjectMetadata.kt`: replace the custom `NonEmptyValue` delegate implementing Gradle's `PropertyDelegate` with a plain helper function taking the `extra`-fallback key explicitly. The three nags remaining under `--warning-mode all` come from Detekt 1.23.8, Kover 0.9.8, and Gradle Doctor 0.12.1; no released versions fix them. They are documented in the new `gradle-10-third-party-deprecations` team memory so they are re-checked on each `dependency-update` run instead of being chased in `buildSrc`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Superseding this PR: the Gradle 9.6 deprecations it targets were already addressed on #719 is the more complete fix — it deletes the deprecated One follow-up worth noting: this branch's discovery run surfaced a third deprecation not in #719's tracking note — Kover 0.9.8's "Using a Project object as a dependency notation" from Closing as superseded by #719. |
What & why
Gradle 9.6 (this repo is on 9.6.1) deprecates the Kotlin DSL delegated-property
accessors and several runtime APIs, all scheduled to become hard errors in
Gradle 10. This branch removes every such usage from our own build logic so
consumer repos that pull
configdon't inherit the nags.Deprecations fixed in
buildSrc(own code)jvm-module.gradle.kts,write-manifest.gradle.ktsval x by tasks.registeringtasks.register(...)kmp-module.gradle.ktsval x by getting(source sets)getByName(...)jacoco-kotlin-jvm.gradle.kts,jacoco-kmm-jvm.gradle.kts,uber-jar-module.gradle.ktsval x by tasks.gettingtasks.named(...)ProjectMetadata.ktNonEmptyValue : PropertyDelegatefunwith explicitextra-fallback keyThe migrations are behavior-preserving:
getByNameis exactly as eager as theold
by getting;register/namedkeep the tasks lazy;ProjectMetadata'sfallback keys (
groupId/artifactId/version) and its failure modes on amissing/non-
Stringextraproperty are unchanged.Verification
./gradlew -p buildSrc build(compile + tests) — green./gradlew detekt(static analysis overbuildSrc) — green--warning-mode allnow shows zero deprecation warnings from our codeResidual third-party nags (documented, not fixable here)
Three warnings remain under
--warning-mode all; all originate in plugins, notour scripts, and no released versions fix them yet:
ReportingExtension.file(String); fix ships only inDetekt 2.0 (still alpha), see detekt#8452
Project.getProperties; no newer releaseThese are captured in a new team-memory note
(
.agents/memory/project/gradle-10-third-party-deprecations.md) so they getre-checked on each
dependency-updaterun rather than chased inbuildSrc.They must be resolved (or the plugins dropped) before adopting Gradle 10.
Note on branch scope
The branch also carries two earlier commits that predate this work and are
included in the diff:
56a72c23(report resolved dependency versions in thePOM report —
DependencyWriter/DependencyWriterSpec) and512c1068(configure the JVM test task in
kmp-module).Reviewer notes (non-blocking)
A pre-PR review pass (
spine-code-review,kotlin-engineer,review-docs) returnedAPPROVE WITH CHANGES with no must-fix items. The should-fixes all concern the
earlier
56a72c23commit and are left for the author's discretion:DependencyWriter.kt:209— the genericcatch (e: Exception)in theresolve-all-configurations loop should rethrow
CancellationExceptionfirst.DependencyWriter.kt:178— inline the single-usemoduleDependencylocal(type-name-as-variable-name).
DependencyWriter.kt:165KDoc — "a version … which carries no explicitversion" reads as a version carrying a version; reword to "a dependency
managed by a BOM, which declares no explicit version".
.agents/tasks/pom-resolved-versions.md— stalebranch: masterandunchecked plan boxes despite
status: in-review(task files are deleted onmerge per
AGENTS.md).🤖 Generated with Claude Code