Integrating Kotlin into Java/Scala project



I was wondering if anyone tried using kotlin-maven-plugin in a mixed Java/Scala project? The docs only provide instructions for the Kotlin/Java case, which of course is understandable, but my use-case is a bit more complex.

I’d like to be able to call all three languages from each other, but I am not sure if this is at all possible? My current setup allows for all use-cases except calling Kotlin from Scala, because the compilation is Scala -> Kotlin -> Java. I haven’t explicitly tried that, but I think if I reorder Kotlin and Scala, Kotlin wouldn’t be able to call Scala.


Kotlin’s Java interop works due to the fact that Kotlin incorporates a parser for Java source code, which allows to reference declarations which haven’t been compiled yet. Kotlin doesn’t incorporate a Scala parser, so it can only invoke Scala code which has been compiled; the reverse is also true. Thus I don’t think that full three-way interop could be possible without a lot of extra work.


Thanks for confirming my expectations. I think this might be a good use-case for Kotlin though, migrating from Java/Scala or Scala only codebases.