Skip to main content

Set up Kotlin source directory from Gradle Kotlin DSL


When converting Android Gradle files from Groovy to Kotlin, one thing that may not be clear is how to keep Kotlin sources within src/main/kotlin. We simply need to get the source sets by name and call java.srcDirs() as a function call. Works like a dream!

sourceSets {

I hope the article was useful. If you have any feedback or questions please feel free to reach out.

Thanks for reading!

Like what you read? Please share the article.

Avatar of Andrew Lord


Andrew Lord

A software developer and tech leader from the UK. Writing articles that focus on all aspects of Android and iOS development using Kotlin and Swift.

Want to read more?

Here are some other articles you may enjoy.