4

In our purely Kotlin project we would like to use flexible Java 9 module system. Otherwise we have to use internal visibility modifier too often to hide internal Kotlin module functionality from other Kotlin modules.

Is it possible to use Jigsaw in Kotlin?

2
  • 1
    I found your question interesting and did some research. I did not find a way to create something like module-info.kt or give an option to the Kotlin Maven or Gradle plugins to have it automatically created. However it is possible to put module-info.java into src/main/kotlin. It's easier with Maven, because everything is put under target/classes. Just take sure, that the Kotlin plugin is triggered before the Maven compiler plugin (eg. put it in phase process-sources) and that you use a version of the Maven compiler that understands META-INF/versions from kotlin.stdlib (e.g. 3.11.0). Commented Jul 2, 2023 at 8:06
  • For Gradle its described here: kotlinlang.org/docs/…. --patch-module is needed, because with Gradle Kotlin classes and Java classes are placed into different directories. You can ignore the warning from kotlinlang.org/docs/… and add sth. like sourceSets { main.java.srcDirs += 'src/main/kotlin' }. If you have specified the JVM target for Kotlin, you must now do the same for Java (e.g. compileJava { sourceCompatibility = '9'; targetCompatibility = '9' }. Commented Jul 2, 2023 at 8:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.