The idiomatic way to add source sets to your Gradle project when using the Kotlin DSL

Originally posted on 2020-11-06

While working with DominoKit I needed to tell the GWT compiler to look for sources that were generated by some annotation processors. I found a lot of references on how to do this for the Groovy DSL and a few for the Kotlin DSL. But one of them stood out as the nicest to me.

Here's what I added to my build.gradle.kts to add the source path for the generated code from the annotation processors:

sourceSets {
    val main by getting"build/generated/sources/annotationProcessor/java/main")