Reputation: 421
I am trying to bundle all libraries to one jar for my JavaFX application using ANT. I found the following Creating a bundle jar with ant but could not get it to work. Adding the library *.jar files can be done in <fx:jar>
by adding <fileset>
:
<fileset dir="build" includes="libs/*.jar"></fileset>
The build
directory contains:
build
|-- classes (compiled classes)
|-- libs (external libraries)
|-- src (sources)
The generated jar now contains the libs
directory with all the libraries.
How can I tell the generated jar that is should look into the libs
directory inside the jar and not outside it?
Thanks!
Upvotes: 3
Views: 2477
Reputation: 421
Thank you jewesea!
I could not make any of those libraries work with JavaFX. But I found this: https://community.oracle.com/message/10266894
so after <fx:jar>
i unpack and repack all libraries and it works.
<target name="do-deploy-bundle" depends="init-properties, do-deploy-dist">
<property name="tmp.file" value="temp_final.jar"/>
<delete file="${dist.dir}/${app.jar}" />
<delete dir="${bundle-dist.dir}"/>
<mkdir dir="${bundle-dist.dir}"/>
<jar destfile="${bundle-dist.dir}/${tmp.file}" filesetmanifest="skip">
<zipgroupfileset dir="${dist.dir}" includes="*.jar" />
<zipgroupfileset dir="${dist.dir}/libs" includes="*.jar" />
<manifest>
<attribute name="Implementation-Vendor" value="${app.vendor}"/>
<attribute name="Implementation-Title" value="${app.name}"/>
<attribute name="Implementation-Version" value="${app.version}"/>
<!--<attribute name="Main-Class" value="com.javafx.main.Main" />-->
<attribute name="Main-Class" value="com.poterion.texovac.application.Main" />
<attribute name="JavaFX-Version" value="2.2" />
<attribute name="JavaFX-Feature-Proxy" value="None"/>
<!--<attribute name="JavaFX-Application-Class" value="com.poterion.texovac.application.Main" />-->
<attribute name="Created-By" value="JavaFX Packager" />
</manifest>
</jar>
<zip destfile="${dist.dir}/${app.jar}">
<zipfileset src="${bundle-dist.dir}/${tmp.file}" excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA , META-INF/maven/**,META-INF/*.txt" />
</zip>
<delete file="${bundle-dist.dir}/${tmp.file}" />
<delete dir="${bundle-dist.dir}"/>
</target>
Upvotes: 5