Mac上的JavaFX部署 - 构建错误“无法生成捆绑”

时间:2016-12-21 13:44:18

标签: java macos javafx

按照本教程http://code.makery.ch/library/javafx-8-tutorial/part7/,我在使用OS X部署javaFX应用程序时遇到了一些麻烦。

这是build.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<project name="Dogsled" default="do-deploy" basedir="."  xmlns:fx="javafx:com.sun.javafx.tools.ant">
<target name="init-fx-tasks">
    <path id="fxant">
        <filelist>
            <file name="${java.home}\..\lib\ant-javafx.jar"/>
            <file name="${java.home}\lib\jfxrt.jar"/>
        </filelist>
    </path>

    <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
        uri="javafx:com.sun.javafx.tools.ant"
        classpathref="fxant"/>
</target>
<target name="setup-staging-area">
    <delete dir="externalLibs" />
    <delete dir="project" />
    <delete dir="projectRefs" />

    <mkdir dir="externalLibs" />


    <mkdir dir="project" />
    <copy todir="project">
        <fileset dir="/Users/steveli/Documents/workspace/Dogsled">
            <include name="src/**" />
        </fileset>
    </copy>

    <mkdir dir="projectRefs" />
</target>
<target name='do-compile'>
    <delete dir="build" />
    <mkdir dir="build/src" />
    <mkdir dir="build/libs" />
    <mkdir dir="build/classes" />

    <!-- Copy project-libs references -->
    <copy todir="build/libs">
        <fileset dir="externalLibs">
        </fileset>
    </copy>

    <!-- Copy project references -->

    <!-- Copy project sources itself -->
    <copy todir="build/src">
        <fileset dir="project/src">
            <include name="**/*"/>
        </fileset>
    </copy>

    <javac includeantruntime="false" source="1.8" target="1.8" srcdir="build/src" destdir="build/classes" encoding="UTF-8">
        <classpath>
            <fileset dir="build/libs">
                <include name="*"/>
            </fileset>
        </classpath>
    </javac>

    <!-- Copy over none Java-Files -->
    <copy todir="build/classes">
    <fileset dir="project/src">
        <exclude name="**/*.java"/>
    </fileset>
    </copy>


</target>
<target name="do-deploy" depends="setup-staging-area, do-compile, init-fx-tasks">
    <delete file="dist"/>
    <delete file="deploy" />

    <mkdir dir="dist" />
    <mkdir dir="dist/libs" />

    <copy todir="dist/libs">
        <fileset dir="externalLibs">
            <include name="*" />
        </fileset>
    </copy>


    <fx:resources id="appRes">
        <fx:fileset dir="dist" includes="Dogsled.jar"/>
        <fx:fileset dir="dist" includes="libs/*"/>
    </fx:resources>

    <fx:application id="fxApplication"
        name="RaceTimer"
        mainClass="sled.timer.address.MainApp"
    />

    <mkdir dir="build/classes/META-INF" />



    <fx:jar destfile="dist/Dogsled.jar">
        <fx:application refid="fxApplication"/>
        <fileset dir="build/classes">
        </fileset>
        <fx:resources refid="appRes"/>

        <manifest>
            <attribute name="Implementation-Vendor" value="Steve Li"/>
            <attribute name="Implementation-Title" value="RaceTimer"/>
            <attribute name="Implementation-Version" value="1.3"/>
            <attribute name="JavaFX-Feature-Proxy" value="None"/>
        </manifest>
    </fx:jar>


    <mkdir dir="deploy" />
    <!-- Need to use ${basedir} because somehow the ant task is calculating the directory differently -->
    <fx:deploy
        verbose="true" 
        embedJNLP="false"
        extension="false"
        includeDT="false"
        offlineAllowed="true"
        outdir="${basedir}/deploy"
        outfile="Dogsled" nativeBundles="dmg"
        updatemode="background" >

        <fx:platform basedir="${java.home}"/>
        <fx:info title="Dogsled" vendor="Steve Li"/>

        <fx:application refId="fxApplication"/>
        <fx:resources refid="appRes"/>
    </fx:deploy>


</target>

这是控制台输出:

BUILD FAILED
/Users/steveli/Documents/workspace/Dogsled/build/build.xml:123: Error: Bundler "DMG Installer" (dmg) failed to produce a bundle.

基本上发生的事情是,每当我尝试构建时,.dmg都不会出现在deploy / bundles文件夹中。我尝试删除build文件夹并重建几次,但无济于事。我在网上找到的任何其他解决方案都不起作用。

注意:我正在使用eclipse和e(fx)clipse插件。

感谢任何帮助。

1 个答案:

答案 0 :(得分:3)

在mac中,dmgs是只读创建dmg时创建的磁盘映像。有时这可能会进入一个奇怪的状态。因此,打开DiskUtility并弹出所有看起来像项目名称的旧磁盘映像并重新运行构建。

如果它仍然出错,请挥挥手并尝试使用类似的工具 install4j [https://www.ej-technologies.com/products/install4j/overview.html] 或amipackage [https://amidb.com/amipackage]