Open Frontrider opened 3 years ago
Hello !
Can you try to add sql module to the jre in your project using jlink --add-modules java.base,java.logging,java.sql --output jre
?
That command made a new jre folder inside the project's folder.
After further fiddling, this is the point when intellij stopped complaining about missing classes again, compilation fails. https://gist.github.com/Frontrider/840406ffa79fbe402f8f0cfc943d189b
With this setup, it finds the modules that we need, and I'm finally getting errors that I may not be able to resolve from my script. I think I need to exclude godot.runtime from the build. https://gist.github.com/Frontrider/60f830de511cd087defe16f8c42d03a8
The module info was a requirement, and for gamedev I'd say it's an absolute must to trim out the fat from our result.
It also looks like that Kotlin may or may not play well with modules yet, if you only have kotlin code and that requires some hacking like setting the kotlin output directory to the same folder as java.
@Frontrider Could you comment these two lines: https://github.com/utopia-rise/godot-kotlin-jvm/blob/39828684e65b7d5c717a716c3d02911f74d4d4ad/kt/plugins/godot-gradle-plugin/src/main/kotlin/godot/gradle/setupConfigurationsAndCompilations.kt#L57 and https://github.com/utopia-rise/godot-kotlin-jvm/blob/39828684e65b7d5c717a716c3d02911f74d4d4ad/kt/plugins/godot-gradle-plugin/src/main/kotlin/godot/gradle/setupConfigurationsAndCompilations.kt#L68 build the engine and try again? My guess is that this excludes your module information from the resulting jar. But that's just a guess. Or provide a minimal reproduction sample so i can test that myself?
I think I might be having a similar issue getting the Exposed library to work:
Exception in thread "main" java.lang.NoClassDefFoundError: java/sql/Driver
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:383)
at java.base/java.lang.Class.forName(Class.java:376)
at org.jetbrains.exposed.sql.Database$Companion.connect(Database.kt:204)
at org.jetbrains.exposed.sql.Database$Companion.connect$default(Database.kt:195)
at com.example.galaxyStream.universe.SubstanceKt.connectDatabase(Substance.kt:162)
at com.example.galaxyStream.universe.Galaxy._ready(Galaxy.kt:59)
at godot.com.example.galaxyStream.universe.GalaxyRegistrar$register$1$1$2.invoke(GalaxyRegistrar.kt:19)
at godot.com.example.galaxyStream.universe.GalaxyRegistrar$register$1$1$2.invoke(GalaxyRegistrar.kt:19)
at godot.core.KtFunction0.invokeKt$godot_library(Functions.kt:103)
at godot.core.KtFunction.invoke(Functions.kt:74)
at godot.core.TransferContext.icall(Native Method)
at godot.core.TransferContext.callMethod(TransferContext.kt:52)
at godot.Node.addChild(Node.kt:806)
at godot.Node.addChild$default(Node.kt:804)
at com.example.galaxyStream.network.JoinServer._process(JoinServer.kt:266)
at godot.com.example.galaxyStream.network.JoinServerRegistrar$register$1$1$11.invoke(JoinServerRegistrar.kt:28)
at godot.com.example.galaxyStream.network.JoinServerRegistrar$register$1$1$11.invoke(JoinServerRegistrar.kt:28)
at godot.core.KtFunction1.invokeKt$godot_library(Functions.kt:113)
at godot.core.KtFunction.invoke(Functions.kt:74)
Caused by: java.lang.ClassNotFoundException: java.sql.Driver
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 30 more
This is pretty much just their getting started guide so that might be a minimal reproduction example. Will try commenting out the lines you mentioned but I haven't tried compiling the engine before.
@chippmann That file seems to have disappeared. Found it here instead, is this the line to comment out now?
@nicola-sorace Did you try to add the sql modules first?
Probably this will be enough: jlink --add-modules java.base,java.logging,java.sql --output jre-amd64
but maybe you need additional modules
Some java 11 modules do not make it to the classpath of the application. This can be a feature as we strip the things we don't need.
Java modules should be taken a look at somewhere down the line.
May not be because of modules, but that is my guess.