Zak Taccardi
09/28/2022, 7:16 PMTaskProvider<Sync>
into a Provider<FileSystemLocation>
and support the config cache? With:
fun TaskProvider<Sync>.asFileSystemLocationSingleFile(): Provider<FileSystemLocation> {
return map {
it.outputs.files.asFileTree.elements.get()
}
.map {
// seeing `> Collection is empty.` error with config cache on
it.first()
}
}
I’m seeing this error:
1 problem was found storing the configuration cache.
- Task `:jenkinsfile:jenkinsfile-shared:modifySharedGroovy` of type `Build_gradle$ModifySharedGroovy`: value 'map(org.gradle.api.file.FileSystemLocation map(map(provider(task 'syncOriginalSharedGroovy', class org.gradle.api.tasks.Sync))) check-type())' failed to unpack provider
Set<FileSystemLocation>
instead of FileSystemLocation
), however works:
fun TaskProvider<Sync>.asFileSystemLocationSet(): Provider<Set<FileSystemLocation>> {
return map {
it.outputs.files.asFileTree.elements.get()
}
}
I think this is because Gradle understands that the Set<..>
is live, and pulling a single FileSystemLocation
out of it breaks that behaviorSet<FileSystemLocation>
when it’s only 1 file - I want to define it as FileSystemLocation
Rodrigo Oliveira
09/28/2022, 9:47 PMfun TaskProvider<Sync>.asFileSystemLocationSingleFile(): Provider<FileSystemLocation> {
return flatMap { sync ->
sync.outputs.files.asFileTree.elements.map { it.first() }
}
}
asFileTree
step looks redundant:
fun TaskProvider<Sync>.asFileSystemLocationSingleFile(): Provider<FileSystemLocation> {
return flatMap { sync ->
sync.outputs.files.elements.map { it.first() }
}
}
Zak Taccardi
09/28/2022, 9:49 PMfun TaskProvider<Sync>.asFileSystemLocationSingleFile(): Provider<FileSystemLocation> {
return flatMap { sync ->
sync.outputs.files.asFileTree.elements.map { it.first() }
}
}
worked! Needed to use .asFileTree
to get the actual file output instead of the directory