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.
Using with Kotlin Multiplatform
Section titled “Using with Kotlin Multiplatform”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:
jextract.libraries { val greeting by registering { // library config } sourceSets.named("jvmMain") { jextract.libraries.addLater(greeting) }}
jextract.libraries { def greeting = register('greeting') { // library config } sourceSets.named("jvmMain") { jextract.libraries.addLater(greeting) }}