Zak Taccardi
10/07/2024, 9:30 PMtask.outputs.files.elements to filter on a file type to get a Provider<FileSystemLocation> and set that as an artifact for an outgoing configuration?
With the following, I get this error: Querying the mapped value of flatmap(provider(task 'kspDebugUnitTestKotlin', class com.google.devtools.ksp.gradle.KspTaskJvm)) before task ':myProject:kspDebugUnitTestKotlin' has completed is not supported
fun File.isYamlFile(): Boolean {
return this.name.endsWith(".yaml")
}
val myTask = tasks.named("kspDebugUnitTestKotlin")
fun TaskProvider<Task>.yamlProvider(): Provider<FileSystemLocation> {
return flatMap { task ->
task.outputs
.files
.elements
}
.map {
it.single { fileSystemLocation ->
fileSystemLocation.asFile.isYamlFile()
}
}
}
artifacts.add(
"someConfiguration,
myTask.yamlProvider()
)
It looks like artifacts.add(..) queries the value of the provider too soon?