0

Kotlin – How to use your Kotlin library in Java Maven projects

This post demonstrates how to use a Maven dependency written in Kotlin in a Java Maven project.

Kotlin Maven Project

Previously, we created a Maven project that only contains Kotlin codes. Please go through the post before reading further.

Kotlin – How to create Maven project for Kotlin

Maven Dependency to use

We now update our pom.xml to include a Maven dependency to this jar.

Where’s the Kotlin Runtime Maven dependency?

Somehow the Kotlin library we created included its pom.xml within the jar file.

The pom.xml already contains the Maven dependency to the Kotlin runtime library.

Using the library

The class name “HelloKt” is based on “Hello.tk” from the Kotlin Maven project.

References

https://kotlinlang.org/docs/reference/using-maven.html

Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert