As the title says, I am trying to mix Java and Kotlin in a single project. There\'s a good example found here. mixed-java-kotlin-hello-world. Everything is working properly besi
you should override sourceSets like this
sourceSets {
main.java.srcDirs = []
main.kotlin.srcDirs = ['src/main/java', 'src/main/kotlin']
main.resources.srcDirs = ['src/main/resources']
}
I had a similar issue and my java code was in the same source directory as the kotlin code
My solution was adding this configuration in build.gradle.kts
:
configure<SourceSetContainer> {
named("main") {
java.srcDir("src/main/kotlin")
}
}