Slackbot
11/03/2022, 6:22 PMVampire
11/03/2022, 6:25 PMVampire
11/03/2022, 6:27 PM@Internal
property and having another property with those annotations derived from that property and then in a map
checking whehter the directory exists and mapping to null
if it does not exist. Something like that.Vampire
11/03/2022, 6:27 PMAndrew Grosner
11/03/2022, 6:29 PM@get:InputFile
@get:SkipWhenEmpty
@get:Optional
@get:PathSensitive(PathSensitivity.RELATIVE)
abstract val buildDir: RegularFileProperty
if (project.buildDir.exists()) {
buildDir.set(project.buildDir)
}
Vampire
11/03/2022, 6:34 PMI didnt have any other threads that I was messaging in , so i may be confused with someone elseNo, you have two threads. The second only contains "adding
@Optional
doesnt work either. it produces same error message".
No, withso not a solution would be turning it into:
RegularFileProperty
you would have the same problemAndrew Grosner
11/03/2022, 6:35 PMAndrew Grosner
11/03/2022, 6:41 PMif (project.buildDir.exists()) {
buildDir.set(project.buildDir)
} else {
buildDir.set(Providers.notDefined())
}
and make it @Optional
i then check in the task to see if its presentVampire
11/03/2022, 6:49 PMProviders
is an internal classVampire
11/03/2022, 6:51 PMbuildDir.set(layout.buildDirectory.flatMap { provider { if (it.asFile.exists()) it else null } })
if you really want to unset it if the directory does not exist.
if there is a convention defined for the property it will then also not be used.Andrew Grosner
11/03/2022, 6:53 PM