Compile Kotlin project and using in Scala project


I need to compile Kotlin project, generate a jar file and in Scala project using this jar like a library, call Kotlin functions and get output, in Scala project.

Have a possible? Any other idea?

It should be possible. Kotlin, like Java and Scala, compiles down to bytecode, and so Scala should be able to use Kotlin classes just like it can use Java classes.

The only wrinkle is that compiled Kotlin tends to make use of classes defined in the Kotlin runtime library, so you’ll need to include that, too — either by copying it into the .jar file you build (a ‘fat jar’), or adding it to the Scala project’s classpath (e.g. using Maven).


For generate a FatJar I’m using a GitHub - johnrengelman/shadow: Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin..

The test works fine! Thx