This message was deleted.
# plugin-development
s
This message was deleted.
m
I could in theory check, before setting the convention, that the directory exists, but it feels wrong as the project directory could be changed later in time
I would like something like
@IgnoreEmptyDirectories
, but for "ignore if not present"
a
https://github.com/gradle/gradle/issues/2016 there are some workarounds here
v
You cannot really. If
@Optional
just means you can "not configure" it. But if it is configured it must be present.
m
this is annoying...
v
Iirc you need some tricks like mapping to
null
if not existing, which makes the property unset and thus
@Optional
kicking in
👍 1
m
sometimes Gradle likes to make thing unnecessarily complicated 🙂
plus1 1
fought with the configuration cache for 2 hours this morning because of non serializable lambdas...
v
Who of us worked for Gradle? 😄
m
I will not comment 🙂
and of course you can't
.map
a
Directory
v
?
Why would you want to?
Directory
is not lazy
m
to check if it exists and return
null
if not
v
You want to map the
DirectoryProperty
, not the
Directory
, don't you? Or what do I get wrong?
m
workaround, wrap it into a directory property. unnecessary boilerplate...
v
Ah, you mean when setting the
DirectoryProperty
to a
Directory
. Yeah, if you want / need to do the exists check there, you need to wrap it in a
provider { ... }
.
The alternative is to do it on the task. Something like having an
@Internal
property the consumer can configure with a possibly non-existing path and a derived property, that is
@InputDirectory
and maps the internal property, doing the null-check.
Something like that
m
yeah I can't do this because it's an extension providing the directory
v
I don't get the point 😞
m
I'm not working at the task level
v
But then input/output annotations shouldn't be considered anyway, should they? confused
m
that's more complicated than that, you know, because of extension vs task properties vs command line argument providers and best practices when it comes to having the same thing everywhere
I have an interface which uses the annotations, so that the annotations are used in task inputs via a nested property
but the extension is used to configure things, and that's what the user sees
v
I see