terminal-recall
terminal-recall copied to clipboard
Terminal Recall cannot be run from a single .JAR
Terminal Recall cannot be run from a single .JAR. For maximum simplicity a single JAR would be nice.
It cannot easily run from a single JAR because the JOGL JAR libraries expect to be outside the jar and so one-jar and shaded plugins confuse it, resulting in fail.
Currently (Mar 06 2014) the POM places the libs in a separate lib/ directory and adds said directory to RunMe.jar's manifest classpath.
It would be optimal to figure out how to get maven to place the lib/ directory in the .JAR, then have extract code explode lib/ outside the JAR with File.deleteOnExit(true). Perhaps the JarInJarLoader can be used?
Then it would all be in one JAR..... most of the time. (:
Using the Maven shade plug-in you can create a "fat jar" containing native libs and all dependencies. Did that already for another project. I'll post a snippet how to do that if you want.
I tried the consolidated JAR approach but unfortunately it doesn't work due to the way JOGL is designed: JOGL's JARs have files of the same name as other JARs' at the root level. When combining them, the shade plugin simply unpacks everything so files apparently get overwritten.
The other issue is that JOGL fails to realize that the native libs are in the home JAR and still looks in the CWD for the external native JARs. On a normal startup, JOGL chooses which JAR to load from based on the machine's native architecture.
Here is a picture to illustrate: Notice that the android-armv6.jar, amd64.jar and linux-armv6.jar all have a libgluegen-rt.so at their root. When they are unpacked and combined into the fat jar they conflict and so only one file is retained. In normal operation JOGL has code which manually chooses which of these to load and leaves the rest alone. To make the system work, the fat jar will have to write temporary files to disk in the arrangement JOGL expects, then following termination, cleans up the files. Some sort of jar-in-jar just in time unpacking trickery may be in store.