Best way to get SourceSet for a Task (specifically JavaCompile)

What is the best way to get the SourceSet for a Task (specifically JavaCompile)?

Is it possible for JavaCompile (or any other Task) to have more than one SourceSet? If so, is there a different methodology for getting multiple SourceSets for a Task than for getting the standard single SourceSet for a Task?

That’s the wrong way round - The task is a low-level construct and has no knowledge about where it came from. In fact, the Android plugin reuses this task without reusing our SourceSet concept at all.

You can get the task for a SourceSet though, using SourceSet.getCompileJavaTaskName