I am working on an executable Java command line program. This is at the testing stage, and packaging it turned out to be a bit of a problem. The essence of this problem is related to the MANY dependencies that my application has. My lib folder (containing jars) is closed at 500mb.
I am currently using the Eclipse Runnable Jar Export wizard. It works flawlessly, except that it needs to be done from Eclipse. It generates a JAR of about 500 MB in size (donβt ask ... suffice it to say that there should be many COBOL programs in this program). This process takes <30 s.
Ideally, I would like it to be some kind of Ant task running through Jenkins and published to the repository. That way, the user can just grab the Jar and run it.
Parameters I investigated:
Custom class loader (FatJar, OneJar, etc.).
- Work
- Slow execution at runtime required to unpack the banner.
- The file structure is basically a Jar filled with banks, and the main class is delegated through a custom class loader.
Fast assembly time (5 minutes)
<target name="hello" depends="compile"> <property name="classes.dir" value="onejar" /> <property name="build.dir" value="bin" /> <one-jar destfile="hello.jar"> <manifest> <attribute name="One-Jar-Main-Class" value="mainclass" /> <attribute name="Class-Path" value="." /> <attribute name="One-Jar-Show-Expand" value="true" /> </manifest> <main> <fileset dir="${build.dir}"/> </main> <lib> <fileset dir="lib"> <include name="**/*.jar"/> </fileset> </lib> </one-jar> </target>
Manually collect dependencies, unpack them into a folder, and then create all kinds of MANIFEST files.
- Cannot get it to work.
- LARGE (1500mb +)
Slow build time (20 min +)
<target name="compile" depends="resolve"> <javac srcdir="src" destdir="bin" debug="true" deprecation="on"> <classpath> <path refid="ivy.path" /> </classpath> </javac> </target> <target name="jar" depends="compile" description="Create one big jarfile."> <jar jarfile="${dist}/deps.jar"> <zipgroupfileset dir="lib"> <include name="**/*.jar" /> </zipgroupfileset> </jar> <sleep seconds="1" /> <jar jarfile="${dist}/myjar.jar" basedir="bin"> <zipfileset src="${dist}/deps.jar" excludes="META-INF/*.SF" /> <manifest> <attribute name="Main-Class" value="mymainclassishere" /> </manifest> </jar> </target>
So does anyone have any suggestions? I am interested in hearing people's thoughts.
Edit: In particular .... WHY the Eclipse Runnable Jar Export Wizard can export my Jar in less than 30 s, but the build time is> 30 minutes.
source share