This message was deleted.
# plugin-development
s
This message was deleted.
g
Couldn't
ConfigurableFileCollection
solve the same? I'm not sure if it's resettable but it's
#from(Any)
method is god-send
r
I'm not sure if it's resettable
You can call
#clear
. The problem is that the user has to call
files.clear()
in that case. The
Property#convention
solution is way more elegant in that respect
t
I would still use a
ConfigurableFileCollection
. Mark your configurable property
@Internal
and add another
@InputFiles
property that checks whether your configurable property is empty and then returns a default value otherwise.
Copy code
@Internal
public abstract ConfigurableFileCollection getMyProperty();

@InputFiles
/* does not need to be public */ FileCollection getActualFiles() {
    var myProperty = getMyProperty();
    if (myProperty.isEmpty()) {
      return getProject().files(…);
    }
    return myProperty;
}

// use getActualFiles() in the task action
👍 2
p
Adding a convention to
ConfigurableFileCollection
would be a good feature request. In the meantime, +1 to Thomas solution
👍 2
r
Nitpick: I'm not sure that that solution can distinguish between
myProperty
being empty and
myProperty
being unset (another thing properties/conventions are good at)