In other deployment formats used by Java/Scala apps, jars are smashed together into either one “uber” jar or zipped into a file that must be uncompressed before running the application with a generated bash script. Both approaches work, but each have their drawbacks. With the uber jar, bad merges of all the jars can cause unpredictable and nasty bugs. With the latter approach, there are security issues that can crop up due to a simple bash script being responsible for gluing the jars into a running JVM application. So my team created an executable jar format that uses its own classloader to load classes and resources from a jar of jars. This allowed for developer classpaths to be used in production deployments with all executable code coming from one signed jar. Here is how our new plugin for a single, signed executable jar file for Scala projects works: It removed the possibility for weird bugs due to different classpaths being used in development and production environments.A JarClassLoader is compiled that enables class files to load from jar files embedded inside of a jar file.A main wrapper is generated that calls either the main-class indicated by the jar file generated by the maven-jar-plugin, or a main-class specified in the configuration of the exec-jar-plugin’s execution. A new jar file is generated that contains the same.Class files as the jar generated by maven-jar-plugin plus all the dependent jars (including the transitive closures i.e.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |