Vampire
02/28/2025, 11:55 AMProperty times I had an @Internal property that was set to either,
and then a derived @Optional @InputFile read-only property
and a derived @Optional @InputDirectory read-only property
which checked whether the internal property is a file or directory
and at execution time checked that exactly one of them is set.
I'm thinking about cleaner ways to rewrite this, without splitting the task into multiple tasks.ephemient
02/28/2025, 12:31 PM@get:Nested var input: Either
interface Either {
abstract class File : Either {
@get:InputFile abstract val file: RegularFileProperty
}
abstract class Directory : Either {
@get:InputDirectory abstract val dir: DirectoryProperty
}
}Martin
02/28/2025, 2:12 PMephemient
02/28/2025, 3:25 PMwhen (val either = input.get()) {
is Either.File -> "Input file: ${either.file.get().asFile.absolutePath}"
is Either.Directory -> "Input directory: ${either.dir.get().asFile.absolutePath}"
}
instead of casting a second getephemient
02/28/2025, 3:27 PMFileCollection