Skip to content

Using Jextract in Kotlin code

Kotlin JVM uses the Java source sets, so Kotlin will find the generated sources. So adding them like in pure Java projects is sufficient.

Kotlin Multiplatform is able to build for a JVM target, but it creates source sets that are named differently than those from the Java plugin. The main source set is named jvmMain in KMP. The bindings are added as follows:

build.gradle.kts
jextract.libraries {
val greeting by registering {
// library config
}
sourceSets.named("jvmMain") {
jextract.libraries.addLater(greeting)
}
}