Just encountered a 'big one' for which I can't fin...
# multiplatform
d
Just encountered a 'big one' for which I can't find any documentation... When creating a KMM library module, targeting JVM on Java 9+, sooner or later we will need to include a java module, how does this work? Where should I specify it? I've tried naively adding
module-info.java
under
<jvmSourceSet>/java
but the IDE is not reacting. My immediate case is to add
java.desktop
to use some AWT classes.
e
for pure jvm projects, you can just put it in
src/main/kotlin
. putting it in
src/main/java
results in Kotlin compiled without module info IIRC for multiplatform, the java directory isn't used unless you specify
kotlin { jvm { withJava() } }
, but try
src/jvmMain/kotlin/module-info.java
first
d
@ephemient Thanks for the suggestions but neither of these worked: • Putting
module-info.java
into
src/jvmMain/kotlin
was ignored (as the IDE warned it would be) • Adding
withJava()
didn't work as my KMM module also has an Android target and the Gradle plugin threw an error saying this was unsupported. I tried adding
--add-modules
to my free compiler args; but since this goes to
kotlinc
and not
javac
it was unsupported too.
This is feeling like a significant hole in Java Modules vs. KMM support 🤔
m
For what exactly do you think you will have to cope with the Java module system? Even with Java 18 EA you can still put everything on the classpath and nobody forces you to use the module system.
d
I want to wrap this map component in a SwingPanel in Desktop Compose.
Simply including it in the project errors that AWT Component is an ancestor class and not included by default in Java 9.
This has been split off into Java module
java.desktop
so I need a way of acquiring that on my class-path.
It doesn't have to be as a Java module per-se but I'm not aware of the standard Java modules having secondary distributions as Gradle Artifacts.
m
Have you tried that in a Compose desktop project? Compose heavily uses AWT internally, so this must already be on the classpath.