Hi everyone, In Kotlin 1.3.40, we are introducing ...
# multiplatform
h
Hi everyone, In Kotlin 1.3.40, we are introducing Java support to JVM targets of multiplatform projects! You can try this feature in the 1.3.40 EAP builds. Previously, the
jvm { ... }
targets ignored Java sources and did not apply the Gradle
java
plugin, which prevented them from proper interoperation with other plugins supporting Java, like the
application
plugin. Now you can configure a JVM target to work with Java, meaning that it will apply the Java plugin to compile Java and setup the model that other plugins may expect. To do that, call
withJava()
in the scope of a JVM target, for example:
Copy code
kotlin {
    jvm {
        withJava()
        /* ... */
    }
}
Note that it is disabled by default. The compilations of such a JVM target are associated with the Java source sets. Kotlin source sets with common code still cannot contain Java. The Java sources must be placed in sibling directories of the Kotlin source roots. For example, with the default JVM target name `jvm`:
Copy code
src
├── jvmMain
│   ├── java // production Java sources
│   ├── kotlin
│   └── resources
├── jvmTest
│   ├── java // test Java sources
│   ├── kotlin
…   └── resources
There are certain limitations at this point; for example, the Java plugin's tasks
jar
and
test
are disabled in favor of the JVM target's ones. As the design is not yet finalized, your feedback is more than welcome! Known issues can be found in https://youtrack.jetbrains.com/issue/KT-26256, see the related tickets.
🎉 13
👍 5