Slackbot
02/22/2023, 1:37 PMVampire
02/22/2023, 1:58 PMMatan Sabag
02/22/2023, 2:04 PMVampire
02/22/2023, 2:09 PMRegularFileProperty
that you annotate with @InputFile
Matan Sabag
02/22/2023, 2:10 PMVampire
02/22/2023, 2:11 PM@Optional
but that means it does not have to be configured. If it is configured, it must still exist.
If you want to support configuring a path but not requiring it to exist you have to do it differently, like having it @Internal
and then having a derived one that is @InputFile
and @Optional
where the provider is empty if the file does not exist.Vampire
02/22/2023, 2:17 PMabstract class MyTask : DefaultTask() {
@get:Internal
abstract val inputFile: RegularFileProperty
@get:Optional
@get:InputFile
val optionalInputFile = inputFile.map {
if (it.asFile.isFile) it else null
}
}
Matan Sabag
02/22/2023, 2:27 PM