Replace Gradle delegated properties with direct assignments#9267
Open
3flex wants to merge 3 commits intodetekt:mainfrom
Open
Replace Gradle delegated properties with direct assignments#92673flex wants to merge 3 commits intodetekt:mainfrom
3flex wants to merge 3 commits intodetekt:mainfrom
Conversation
Gradle discourages the use of Kotlin delegated properties (the `by` keyword) in build scripts because the delegation mixes registration semantics with eager/lazy lookups in non-obvious ways and interferes with upcoming Gradle features. See gradle/gradle#37555 for motivation. Convert every `val x by tasks.registering(...)` / `val x by configurations.{registering,dependencyScope,resolvable, consumable}` declaration in the repo's build scripts and convention plugins to the non-delegated form `val x = tasks.register<T>("x") {}` / `val x = configurations.register("x")` etc. The resulting variables hold the container's `(Named)DomainObjectProvider<T>` directly, so a few call sites needed `.get()` to unwrap the provider: - `Configuration.extendsFrom(...)` requires a realized `Configuration`, so `extendsFrom(fooProvider.get())` replaces `extendsFrom(fooProvider)` in detekt-cli, detekt-generator, and releasing.gradle.kts. - `JavaExec.classpath` is assigned via `files(detektCliClasspath)` in detekt-generator so the provider is adapted to a FileCollection. - `pluginsJarFiles.files.joinToString(...)` becomes `pluginsJarFiles.get().files.joinToString(...)` in detekt-cli. The unused `val test` in detekt-sample-extensions' `suites { }` block is dropped in favor of `named<JvmTestSuite>("test") { ... }`. No task names, configuration names, or behavior change. Co-authored-by: Claude <claude@anthropic.com>
3flex
commented
Apr 21, 2026
| extendsFrom(releaseArtifacts) | ||
| val releaseArtifacts = configurations.dependencyScope("releaseArtifacts") | ||
| val releaseAssetFiles = configurations.resolvable("releaseAssetFiles") { | ||
| extendsFrom(releaseArtifacts.get()) |
Member
Author
There was a problem hiding this comment.
We should be able to get rid of the get() again when we update to Gradle 9.4.
https://docs.gradle.org/current/release-notes.html#configurationextendsfrom-accepts-providers
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9267 +/- ##
=======================================
Coverage ? 84.83%
Complexity ? 4433
=======================================
Files ? 569
Lines ? 12319
Branches ? 2719
=======================================
Hits ? 10451
Misses ? 689
Partials ? 1179 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Use of Kotlin delegated properties (the
bykeyword) in build scripts will be deprecated from Gradle 9.6. See gradle/gradle#37555.