Gradle are deprecating the delegated properties ut...
# community-support
a
Gradle are deprecating the delegated properties utils, e.g.
val foo by tasks.registering
https://github.com/gradle/gradle/pull/37556 I rather like these utils. They help make buildscripts more concise. I've created an issue to restore them https://github.com/gradle/gradle/issues/37604. Does anyone have thoughts on this?
t
I've always hated those utils so I'm glad they're on the way out. I think it makes parsing build scripts a pain. The standard APIs are imo less verbose for many cases, and much more easily discoverable
5
a
do you mean parsing visually, or are you using some tool to programatically parse them?
the standard APIs are patently more verbose, since they require duplicating the task name & variable
t
programmatically parsing. I have several tools that use antlr to parse build scripts and the Kotlin DSL constructs turn into much more complex parse trees and disagree on the other point.
Copy code
tasks.register("foo") {}
is better than
Copy code
val foo by tasks.registering {}
it is not only literally shorter but also doesn't result in unused variables in build scripts, which clutter my IDE interface
👍 1
p
I did like them in the past, but it is Kotlin only, and does not work with programmatic task names. And mixing the syntax in one plugin is awkward too. Also, it makes only sense if you need the variable, otherwise you have an unused variable.
3
v
and disagree on the other point.
Copy code
tasks.register("foo") {}
is better than
Copy code
val foo by tasks.registering {}
Matter of point of view. But the point to compare (or also compare) is
Copy code
val foo = tasks.register("foo") {}
which is longer than both the other variants and requires that you duplicate the name, unless you want the variable have a different name.
it is not only literally shorter but also doesn't result in unused variables in build scripts, which clutter my IDE interface
I think it is several years ago that my IDE has shown those variables as unused, because they are used. Their name defines the name of the element that is created or retrieved. It was only in the beginning of that all where the my IDE has shown them wrongly as unused.
Also, it makes only sense if you need the variable, otherwise you have an unused variable.
It is not unused, its name is used and the IDE knows that since years and does not show them as unused.
Does anyone have thoughts on this?
I would greatly support having those stay and even extended. Unfortunately, it was long clear that this step will come. When the Gradle folks did not add such delegate property helpers for the new role-defined configuration helper methods (
val foo = configurations.resolvable("foo")
) and when I requested them to be added 2.5 years ago, they already said that they will eventually remove the existing ones too (https://github.com/gradle/gradle/issues/27204) 😞 So we probably will have a hard stand getting them to change their mind. This probably needs to go into some library, providing that functionality is possible.
1