2

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!

4

1 回答 1

5

谢谢你!

我无法使这些库中的任何一个与 JavaFX 一起使用。但我发现了这个:https ://community.oracle.com/message/10266894

所以在<fx:jar>我解压缩并重新打包所有库之后它就可以工作了。

<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>
于 2014-01-11T13:17:56.667 回答