How to add new sourceset with gradle kotlin-dsl
You should try the following:
java.sourceSets.create("src/gen/java")
Hope it's what you need!
The answer of @s1m0nw1 is correct to add a new sourceset. But to just add a new source-folder in an existing sourceset, this can be used:
java.sourceSets["main"].java {
srcDir("src/gen/java")
}