Slackbot
12/11/2023, 8:07 PMJendrik Johannes
12/11/2023, 8:23 PMget() as part of the configuration, it it an indication that something can be improved. When you call get() on a Provider you may loose certain meta information – like which task is responsible for creating the value behind the provider. That's why the getAllFiles task does not run automatically here.
Instead your expression should start with:
val zips = getAllFiles.map { ... }
In this setup you also do not necessarily need two tasks, but could directly use the configuration as input to `organizeTransitiveJsResources`:
val zips = configurations.foo.elments.map { it.map { zipTree(it) } }
Note that this is always slightly confusing, because one map is the Provider.map of Gradle and the other is the Iterable.map of Kotlin.
I recently did a video on the topic that has an example very similar to this:
https://github.com/jjohannes/understanding-gradle/blob/main/35_Working_with_Files/[…]gic/java-plugins/src/main/kotlin/my-java-application.gradle.ktsIvan CLOVIS Canet
12/11/2023, 8:29 PMCannot expand ZIP '/[…]/build/distributions/core-assets.zip' as it does not exist.Jendrik Johannes
12/11/2023, 8:33 PMconfiguration.foo directly? There are a lot of eager methods and it is very easy to get it wrong unforuntately.
E.g. you have to do foo.elments.map {} (with elements ) which maps the configuration to the Provider API.Ivan CLOVIS Canet
12/11/2023, 8:34 PMIvan CLOVIS Canet
12/11/2023, 8:34 PMProvider<Provider<FileTree>> which from doesn't likeJendrik Johannes
12/11/2023, 8:35 PMConfiguration API is historically full of traps....Jendrik Johannes
12/11/2023, 8:35 PMtransitveJsResources.map is the Kotlin map (you don't want that)Jendrik Johannes
12/11/2023, 8:35 PMtransitveJsResources.elements.map (the Gradle map)Jendrik Johannes
12/11/2023, 8:36 PMIvan CLOVIS Canet
12/11/2023, 8:36 PMtransitiveJsResources is a Provider<Configuration> , it is Provider.mapJendrik Johannes
12/11/2023, 8:36 PMJendrik Johannes
12/11/2023, 8:37 PMelements.get().map is wrong 😄Jendrik Johannes
12/11/2023, 8:37 PMJendrik Johannes
12/11/2023, 8:38 PMtJsRessources.get().elements.map {}
But the Provider<Configuration> thing is also confusing to me. Configuration is already lazy. So that is double lazy. I don't know why that is a thing at all...Ivan CLOVIS Canet
12/11/2023, 8:38 PM> Cannot convert the provided notation to a File or URI: [/[…]/build/distributions/core-assets.zip].Ivan CLOVIS Canet
12/11/2023, 8:38 PMget isn't great hereJendrik Johannes
12/11/2023, 8:40 PMit.map { zipTree(it) }
because there you then have the list of Zip filesIvan CLOVIS Canet
12/11/2023, 8:41 PMIvan CLOVIS Canet
12/11/2023, 8:43 PMa.zip
b.zip
I would like to see the output
build/
extracted/
a/
(contents of a.zip)
b/
(contents of b.zip)
whereas currently I get
build/
extracted/
(contents of a.zip)
(contents of b.zip)
(all ZIPs are merged)Jendrik Johannes
12/11/2023, 8:58 PMzipTreeJendrik Johannes
12/11/2023, 8:59 PMfrom(...) {
eachFile {
path = "some-name/$path"
}
}
But you don't know what "some-name" should be at that point anymore.Jendrik Johannes
12/11/2023, 9:00 PMIvan CLOVIS Canet
12/11/2023, 9:00 PMVampire
12/12/2023, 10:33 AMfrom(configurations.foo); into(destination).