Slackbot
11/15/2023, 10:58 PMVampire
11/15/2023, 11:18 PM[...]
it does the following for each property before the task executes:
[...]
•- verifies that the path doesn’t match a file and also creates the directory if it doesn’t already exist.@OutputDirectory
Vampire
11/15/2023, 11:19 PM@Optional should have any influence.
@Optional on an input file or directory property does not mean you can configure a non-existing path.
It means that you are allowed to not configure it, but if you configure it, it must exist (when an input)Kelvin Chung
11/15/2023, 11:20 PM@OutputDirectory annotated with @Optional, and set it, expecting the directory to exist, only to encounter an error stating that it didn't.Vampire
11/15/2023, 11:46 PMabstract class Foo : DefaultTask() {
@get:Optional
@get:OutputDirectory
abstract val out: DirectoryProperty
@TaskAction
fun foo() = Unit
}
val foo by tasks.registering(Foo::class) {
out = layout.buildDirectory.dir("foo")
}
When I executed the foo task, the directory was created as expected.Kelvin Chung
11/16/2023, 12:03 AM@Nested output properties, then? On paper, it shouldn't, but, barring external factors, I don't see why an @OutputDirectory property would fail to create the directory. (Maybe nested directories? Hard to say.)Vampire
11/16/2023, 12:04 AMKelvin Chung
11/16/2023, 12:05 AMVampire
11/16/2023, 12:07 AMinterface Bar {
@get:OutputDirectory
val out: DirectoryProperty
}
abstract class Foo : DefaultTask() {
@get:Nested
abstract val bar: Bar
@TaskAction
fun foo() = Unit
}
val foo by tasks.registering(Foo::class) {
bar.out = layout.buildDirectory.dir("foo")
}Vampire
11/16/2023, 12:07 AM