Francisco Prieto
05/26/2025, 10:53 PM@SkipWhenEmpty for a single file?
I’d like to configure the input of a task in such a way that the task is skipped if:
• The file doesn’t exist.
• The input is set with a provider { null } .
I think this PR asks for something similar, but I couldn’t make it work with a file collection.Francisco Prieto
05/26/2025, 10:55 PM@get:Optional
@get:InputFiles
@get:PathSensitive(PathSensitivity.NONE)
val sourcemap: RegularFileProperty = objectFactory.fileProperty()
and this:
@get:InputFiles
@get:SkipWhenEmpty
val sourcemap: ConfigurableFileTree = objectFactory.fileTree()
but when setting the input like this:
task.sourcemap.set(project.provider { null })
the task isn’t skipped.Francisco Prieto
05/26/2025, 10:56 PMVampire
05/27/2025, 1:31 AM@Optional means "do not file if there is not value set", not "skip if no value set".
Replace @Optional by @SkipWhenEmpty and it works. (the latter implies the former)
And maybe replace @InputFiles by @InputFile, it feels strange to have the plural on a singular property. I didn't even now that works.Martin
05/27/2025, 8:38 AMit’d be nice if the task was just skippedOut of curiosity, is there anything to this besides a nicer log output? Like does it come with better performance or anything like this?
Francisco Prieto
05/27/2025, 12:43 PMLike does it come with better performance or anything like this?Probably not a big impact for just one task, but I’d like the tasks that depend on the skipped task to be skipped too.
Francisco Prieto
05/27/2025, 12:44 PMVampire
05/27/2025, 12:46 PMonlyIf on the depending task and for example check didWork property on the skipped task.
Just that you knowFrancisco Prieto
05/27/2025, 12:56 PMMartin
05/27/2025, 12:57 PMVampire
05/27/2025, 1:44 PMMartin
05/27/2025, 2:37 PM