Philip W
04/30/2025, 8:36 AMPhilip W
04/30/2025, 8:38 AMmyFile.set(layout.file(configuration.map { it.singleFile }))
Would this support lazy configurations?Martin
04/30/2025, 8:45 AMMartin
04/30/2025, 8:46 AMMartin
04/30/2025, 8:46 AM.elements
Martin
04/30/2025, 8:46 AMlayout.file(configuration.elements.map { it.single().asFile })
Vampire
04/30/2025, 9:38 AMVampire
04/30/2025, 9:38 AMVampire
04/30/2025, 9:39 AMconfiguration.map
iirc would loose eventually present task dependenciesVampire
04/30/2025, 9:41 AMelements
for, as bridge from FileCollection
to Provider
Philip W
04/30/2025, 9:41 AMVampire
04/30/2025, 9:42 AMPhilip W
04/30/2025, 9:44 AMmyFile.set(configuration.flatMap { it.elements.map { it.single() as RegularFile } })
Philip W
04/30/2025, 9:45 AMVampire
04/30/2025, 9:46 AMflatMap
yes, as configuration
is a provider in your case, so the snippet was not fully working for you.Vampire
04/30/2025, 9:46 AMRegularFile
, well, if it works it works, but that is not too type-safe I'd say 😄Vampire
04/30/2025, 9:47 AMelements
view probably does not know whether something is a file or directory, so maybe it is not a RegularFile
Philip W
04/30/2025, 9:47 AMVampire
04/30/2025, 10:06 AMc.map { it.singleFile }
misses task dependency
layout.file(c.flatMap { it.elements.map { it.single().asFile } })
and c.flatMap { it.elements.map { it.single() as RegularFile } }
preserve the task dependency
But c.flatMap { it.elements.map { it.single() as RegularFile } }
fails when you try to query the files with
> class org.gradle.api.internal.file.DefaultFileSystemLocation cannot be cast to class org.gradle.api.file.RegularFile (org.gradle.api.internal.file.DefaultFileSystemLocation and org.gradle.api.file.RegularFile are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @66133adc)
Philip W
04/30/2025, 10:07 AM