Maven with Kotlin and Java source in same directory?

I read the docs on using Maven here, and got it working.

It uses separate directories for Java and Kotlin files:

src/
  main/
    java/
    kotlin/

Is there a way to put both .kt and .java files in src/main/java? That would help with introducing Kotlin in one of my projects.

Have you tried just placing .kt files in src/main/java?
I believe this should already work with the linked configuration, as there is <sourceDir>${project.basedir}/src/main/java</sourceDir> configured as source directory for kotlin-maven-plugin.
If you don’t want to use the src/main/kotlin source directory at all, you could just remove respective sourceDir.

1 Like

That appears to work fine. For some reason I thought it didn’t. :man_facepalming: Thank you.

Also, you can take a look at this article. It explains some tweaks to ensure interop works in both sides (java -> kotlin and kotlin -> java).