It looks like things have changed in Gradle 2.12 which now crashes when I use DefaultSourceDirectorySet, which is fine, since it is an internal API. (In particular, it gives the message “Could not create an instance of type org.gradle.api.internal.file.DefaultSourceDirectorySet_Decorated.”)
The question I have then is, what is the alternative? Do I need to implement my own SourceDirectorySet? Or is there some public way of doing this easily that I am just unaware of?
Note that you don’t have to implement SourceDirectorySet. You can define an interface with just the API you care about yourself, like I did for instance in the Xtext plugin.
I currently don’t know of a plan to make the DefaultSourceDirectorySet of the current Gradle model public.
The new software model already provides a public API for defining custom LanguageSourceSets.
P.S Some self-promotion following: You can also read about this in the (free) sample version of Idiomatic Gradle at http://samples.leanpub.com/idiomaticgradle-sample.pdf (Just go to the Add SourceSet Support for JVM Language recipe).
I found that in Gradle 4.10.2 SourceDirectorySetFactory is available
from project.services (ProjectScopeServices),
not project.gradle.services (GradleScopeServices).