4 Comments
Jul 17, 2023Liked by Ken Kousen

I also never understood the Groovy hate, for mostly the reasons you list there Ken.

Expand full comment

I won't be able to get the Lion Sleeps Tonight out of my mind.

Expand full comment

The Kotlin version of the unzip task can be simplified:

tasks.register<Copy>("unzip") {

from(zipTree(tasks.named<Zip>("zip").map { it.archiveFile }))

into(layout.buildDirectory.dir("expanded"))

}

```

You don't need to get the file out of the `archiveFile`, you didn't do that in Groovy, either. Note that the task dependency is inferred as well, since the `archiveFile` carries the task dependencies, as seen in this build scan: https://ge.gradle.org/s/7l2dupq4uvvss/timeline?details=dbh7ehvqq2xq2&show=predecessors

If you don't like the `map`, you can also force the realization of the zip task by using the first get:

```

tasks.register<Copy>("unzip") {

from(zipTree(tasks.named<Zip>("zip").get().archiveFile))

into(layout.buildDirectory.dir("expanded"))

}

```

Expand full comment
author

That is much simpler. Thanks! Looks like I'll need to make another video :⁠-⁠)

Expand full comment