How to create SourceSetContainer?

I am writing a plugin that will be applied to projects that will not necessarily contain Java source. But I really want to leverage SourceSetContainer to simply create a new SourceSet for this plugin’s sources.
Since the JavaPlugin will not necessarily be applied I am wondering how I can create an instance of SourceSetContainer and inject it properly into the Project.

Looking at the JavaPlugin/JavaPluginConvention source, it seems I need to reference an internal class to get this to work. Am I missing something there?

Also, how is that reference made available to the project DSL? I would have assumed the Project’s extension-container, but the JavaPluginConvention never seems to register it anywhere.

So I guess in general, how can a plugin make sure that the concept of SourceSetContainer / sourceSets{} gets added to the project like JavaPlugin does?

Nevermind - I ended up doing this a separate way, although that opened up a new question - InputChanges and SourceSetOutput