It is perfectly valid to cache the result of an expensive calculation. Note that you could create a
FileCollection with only one
Callable (or a
Closure) inside, the
Callable memoizing its result.
This way, calling the getter does not cause evaluation of the
Callable - only resolving the file collection itself does - and that would happen fewer times than the getter is called (currently twice for up-to-date checks I think). It still would make sense to cache the result of the
Callable, so the expensive calculation is only done once.
The only problem which can arise is if the calculation happens to early and the build script changes the task property after it has been evaluated the first time. This is the reason why I would move the code into a
FileCollection, so the actual calculation is done later.
We may provide some infrastructure for this common use case at a later point (something like a lockable
FileCollection), but I cannot make any promises for now.