This message was deleted.
# configuration-cache
s
This message was deleted.
z
This (using
Set<FileSystemLocation>
instead of
FileSystemLocation
), however works:
Copy code
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 behavior
However - I don’t want to define my task input as
Set<FileSystemLocation>
when it’s only 1 file - I want to define it as
FileSystemLocation
r
Perhaps the following would work:
Copy code
fun TaskProvider<Sync>.asFileSystemLocationSingleFile(): Provider<FileSystemLocation> {
    return flatMap { sync ->
        sync.outputs.files.asFileTree.elements.map { it.first() }
    }
}
The
asFileTree
step looks redundant:
Copy code
fun TaskProvider<Sync>.asFileSystemLocationSingleFile(): Provider<FileSystemLocation> {
    return flatMap { sync ->
        sync.outputs.files.elements.map { it.first() }
    }
}
z
I’ve had so many issues with flatmap tbh bc it switches the provider and seems to break the chain of dependent tasks, but I’ll try it
Copy code
fun 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
🎉 1