2

I’m creating an installable bundle for a JavaFX 8 application using the Oracle tool that comes with the JDK. On a Mac a .dmg file is created and on Linux a .deb file is used. I call an Ant script from Gradle to create the bundle. The problem that I have is that the version number contained in the bundle is always 1.0 and not the version that I specify. The relevant part of the Ant script is as follows:

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

    <target name="jfxbundle" description="Build the application bundle">
        <fx:deploy outdir="${basedir}/build"
                   nativeBundles="${packageType}">

            <fx:application refId="VocabHunterId"
                            version="${version}"/>

            <fx:bundleArgument arg="mac.CFBundleVersion"
                               value="${version}"/>
            ...
        </fx:deploy>
        ...
    </target>
    ...
</project>

You can see the full script in context here.

On a Mac, right-clicking the application icon and selecting “Get Info” shows 1.0 instead of the correct version number as you can see in the following screenshot:

Mac Screenshot

Similarly, on Linux the version number shows as 1.0 during the installation of the .deb file:

enter image description here

Does anyone know how to fix Ant script so that the correct version appears?

I'm using Oracle JDK 1.8.0_66 on both the Mac and on LInux.

Adam
  • 682
  • 1
  • 6
  • 27
  • 1
    Where do you define the version variable? – hotzst Jan 19 '16 at 12:03
  • @hotzst The version number is defined in the Gradle script that calls the above Ant script. To remove any doubt, I just did a test on the Mac and hardcoded the version number into the Ant script and I still observe the same problem in the generated bundle. – Adam Jan 19 '16 at 13:17

2 Answers2

2

I've finally solved this. The problem it would seem, was caused by the fact that I had a <fx:application> element with a refid attribute referring to a separate <fx:application>. The solution was to combine these two <fx:application> elements into a single element, as follows:

<fx:application id="VocabHunterId"
                name="VocabHunter"
                mainClass="${mainClass}"
                version="${version}"/>

I found that I had to include the id="VocabHunterId" attribute for some reason: without it the file association did not work.

I've tested this out and it works nicely showing the version number correctly for the installed bundle on OS X 10.11.4 with Oracle JDK 1.8.0_77 and on Ubuntu 14.04 also with Oracle JDK 1.8.0_77. If you'd like to see the full script (including this fix) in context, you can find it here.

Adam
  • 682
  • 1
  • 6
  • 27
0

Taking a look at the Ant task reference, shows that there is mention of a version attribute on fx:application.

You might get away with defining the version in the Manifest, but I am unsure if this will show up in the desired manner.

hotzst
  • 7,238
  • 9
  • 41
  • 64
  • Thanks. Your suggestion about the manifest is an interesting one. I tried adding `Implementation-Version` and `Specification-Version` to the generated Jar and reran the build on Linux but I still see the same problem. As for the `version` attribute in `fx:application`, if you look closely at the XML in the question, it is already specified. So no luck I’m afraid. – Adam Jan 20 '16 at 08:22