Please document how to add modules
Hi, after lurking the old issues and trying several options, I still could not find how to add modules. I see that the issues there and under Kotlin are now solved, but I can find no documentation nor working examples. Could you document how to do so?
e.g., I expected:
@file:KotlinOpts("-J'--add-modules java.scripting'")
println(ScriptEngineManager())
to work, but it does not.
The pure kotlin way is
kotlin -howtorun script -J'--add-modules' -J'java.scripting' my_script.kts
with my_script.kts being
import javax.script.ScriptEngineManager
println(ScriptEngineManager())
Using kscript this should translate to (see https://discuss.gradle.org/t/gradle-does-not-honor-add-modules-jvm-argument-in-jdk9/20403)
@file:KotlinOpts("-J'--add-modules' -J'java.scripting'")
//@file:CompilerOpts("-J'--add-modules' -J'java.scripting'")
import javax.script.ScriptEngineManager
println(ScriptEngineManager())
but this fails with Caused by: java.lang.ClassNotFoundException: javax.script.ScriptEngineManager. I don't know why, but given the history, I'd suspect the kotlin scripting classloader to not handle modules correctly. But this is just a weak guess.
Sorry for the inconvenience.