JavaFX的独立的应用程序包装为Mac没有JRE [英] JavaFX Self-Contained Application Packaging for Mac without JRE

查看:755
本文介绍了JavaFX的独立的应用程序包装为Mac没有JRE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JavaFX 8桌面应用程序,我创建一个的.app <​​/ code>应用程序包分发应用程序的Mac用户。为了保持规模的时候,我创建一个不包含JRE(用户必须具有Java已经安装使用生成的包)。捆绑

I have a JavaFX 8 desktop application and I'm creating an .app application bundle to distribute the application to Mac users. To keep the size down, I create a bundle that doesn't contain the JRE (the user must have Java already installed to use the generated bundle).

我的版本是一个摇篮脚本,但自从甲骨文独立的应用程序打包工具使用Ant的作品,我打个电话到Ant脚本如下:

My build is a Gradle script but since the Oracle "Self-Contained Application Packaging" tool works with Ant, I make a call out to an Ant script as follows:

ant.importBuild 'mac-bundle-ant.xml'

Ant脚本本身则是这样的:

The Ant script itself then looks like this:

<project name="VocabHunter Packaging" basedir=""
         xmlns:fx="javafx:com.sun.javafx.tools.ant">

    <property environment="env"/>
    <property name="JAVA_HOME" value="${env.JAVA_HOME}"/>

    <target name="jfxbundle" description="Build the application bundle">

        <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
                 uri="javafx:com.sun.javafx.tools.ant"
                 classpath="${JAVA_HOME}/lib/ant-javafx.jar"/>

        <fx:application id="VocabHunterId"
                        name="VocabHunter"
                        mainClass="io.github.vocabhunter.gui.distribution.PackagedVocabHunter"/>

        <fx:resources id="applicationResourcesId">
            <fx:fileset dir="${basedir}/build/libs"/>
        </fx:resources>

        <fx:deploy outdir="${basedir}/build"
                   nativeBundles="image">

            <fx:platform basedir=""/>

            <fx:application refId="VocabHunterId"/>

            <fx:resources refid="applicationResourcesId"/>

            <fx:info title="VocabHunter">
                <fx:association description="VocabHunter session"
                                extension="wordy"
                                mimetype="application/x-vnd.VocabHunterSession"
                                icon="${basedir}/icons/mac/VocabHunterSession.icns"/>
            </fx:info>

            <fx:bundleArgument arg="icon"
                               value="${basedir}/icons/mac/VocabHunter.icns"/>

        </fx:deploy>

    </target>

</project>

问题是,生成的的.app <​​/ code>捆绑不起作用。看里面,我发现以下问题行内容/的Java / VocabHunter.cfg

app.runtime=$APPDIR/PlugIns/Java.runtime

如果我摆脱这一行那么的.app <​​/ code>包按预期工作。现在我已经添加了下面的技巧,以我的摇篮脚本来解决此问题:

If I get rid of this line then the .app bundle works as expected. For now I've added the following hack to my Gradle script to work around the problem:

jfxbundle.doLast {
    FileTree tree = fileTree(dir: 'build/bundles').include('**/*.cfg')
    tree.each {File file ->
        String content = file.text.replaceAll('(?m)^app\\.runtime=.*$\n', '')
        file.write(content)
    }
}

您可以看到完整的code rel=\"nofollow\">。

You can see the full code here.

有谁知道如何解决Ant脚本,从而避免在摇篮文件?

Does anyone know how to fix the Ant script and thus avoid the need for the hack in the Gradle file?

在完整性的利益,我使用Oracle JDK 1.8.0_66为Mac。

In the interests of completeness, I'm using the Oracle JDK 1.8.0_66 for Mac.

推荐答案

这个错误开始从Java 1.8.0更新60存在,我已经报这一点,但它不是一个正式的错误呢。

This bug starts to exist from java 1.8.0 update 60, I already reported this but it's not a official bug yet.

问题是使用INI文件格式,现在,你可以看到的此处我的发现。

The problem is the internal packager using INI-file-format now, you can see my findings here.

您应该能够设置捆绑参数的发射-CFG-格式与价值托(<一href=\"https://github.com/javafx-maven-plugin/javafx-maven-plugin/blob/ea272f3b03f9ff8d457992fc12ccae156194849e/src/main/java/com/zenjava/javafx/maven/plugin/NativeMojo.java#L428\"相对=nofollow>喜欢这里)

You should be able to set the bundle-argument "launcher-cfg-format" with the value "prop" (like here)

免责声明:我是JavaFX的Maven的插件的维护者......和不使用gradle这个,但这应该尽可能我可以看到添加:

disclaimer: I'm the maintainer of the javafx-maven-plugin ... and dont use gradle, but this should be added as far as I can see:

        <fx:bundleArgument arg="launcher-cfg-format" value="prop"/>

这篇关于JavaFX的独立的应用程序包装为Mac没有JRE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆