Gama11
09/03/2021, 1:17 PMtasks.withType<KotlinCompile>().configureEach {
and tasks.withType<KotlinCompile> {
? It seems like the configureEach
is redundantFleshgrinder
09/03/2021, 1:22 PMwithType<T>(action)
is equivalent to withType<T>().all(action)
which is an eager API. Meaning, every task is realized and the action is immediately executed. Every task that is going to be added to the task collection is immediately realized and the action is executed.
withType<T>().configureEach(action)
on the other hand is a lazy API. No task gets realized and the action is not executed. When any of the tasks the action was registered for gets realized, the action is executed.
As you can see, there's a big difference. Always prefer withType<T>().configureEach(action)
unless you have a good reason not to.Gama11
09/03/2021, 1:26 PMtasks.test.configure {
vs tasks.test {
?Gama11
09/03/2021, 1:27 PMFleshgrinder
09/03/2021, 1:40 PMtasks.test { }
uses named
in the background and is lazy. You can always use jump to source and check out what it does behind the scenes. 🙂
Totally agree! IntelliJ has lots of issues with many of the modern and more recent changes and additions in Gradle. I guess it doesn't have such a high priority in general.Gama11
09/03/2021, 1:44 PM