task.sourceDirs.setFrom({
extension.mainSourceSets.get()*.allSource*.srcDirs
} as Callable<Set<SourceDirectorySet>>)
There were two elements which prevent me from doing it before:
I missed originally try to play with Closure, but it didn’t work due to missing .srcDirs in my code which resulted in empty FileCollection which was failing my test.
Closure has to be coerced into Callable with a proper type to help determine what is returned to prevent:
java.lang.ClassCastException: class ArrayList1_groovyProxy cannot be cast to class java.util.Iterator (ArrayList1_groovyProxy is in unnamed module of loader org.codehaus.groovy.runtime.ProxyGeneratorAdapter$InnerLoader @38f617f4; java.util.Iterator is in module java.base of loader ‘bootstrap’)
That was the first thing that sprang to my head. As a downside, it would overblow that interface, still probably not covering all the cases that available.
Yeah, the interface would become much bigger, without covering all the cases. So for now, I think the Javadoc is enough. Do you have some improvements for the Javadocs?