Most effective way to add a Java source set to a project

What is the most effective, performant, and concise way to add a Java source set to the build of a project?

In the Gradle 5.6 Kotlin DSL, this is the best I’ve found:

val xyzSourceSet = sourceSets.register("xyz")
tasks.classes {
	dependsOn(xyzSourceSet.get().compileJavaTaskName)
}