Running Griffon Applications with JavaFX 11

JavaFX 11 has just been released! You can get the latest release and find more documentation about it at https://openjfx.io.

Java 11 is just around the corner too. In order to prepare yourself for what's coming here are the first details on modifying your Maven and Gradle builds to compile and run your Griffon project.

Maven

  1. Make sure to have the latest Maven version installed. The current version is 3.5.4.
  2. Edit the pom.xml file and add a couple of additional properties
    <plugin.compiler.version>3.8.0</plugin.compiler.version>
    <javafx.version>11</javafx.version>
  3. Add the following dependencies to the <dependencies> block
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-base</artifactId>
        <version>${javafx.version}</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-graphics</artifactId>
        <version>${javafx.version}</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>${javafx.version}</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>${javafx.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>javax.annotation-api</artifactId>
        <version>1.3.2</version>
    </dependency>
  4. Install a release of Java 11 (currently still in Early Access) from http://jdk.java.net/11.
  5. Remove the usage of the maven-javafx-plugin as it won't work with JavaFX 11 or greater.
  6. Launch the application by invoking mvn -Prun.

Gradle

  1. Make sure to have at least Gradle 4.10 installed.
  2. Edit the build.gradle file and add the osdetector-gradle-plugin to the buildscript or plugins block.
    buildscript {
        repositories {
            maven { url 'https://plugins.gradle.org/m2/' }
        }
    
        dependencies {
            classpath 'com.google.gradle:osdetector-gradle-plugin:1.6.0'
        }
    }
    
    apply plugin: 'com.google.osdetector'
  3. Define a project variable with the resolved platform. Note that ossdetector identifies MacOSX as osx but the JavaFX artifacts require mac.
    ext.platform = osdetector.os != 'osx' ? osdetector.os : 'mac'
  4. Comment out (or delete) the uses of the javafx-plugin.gradle file and the jfx block.
  5. Add the following dependencies to the dependencies block
    compile "org.openjfx:javafx-base:11:${platform}"
    compile "org.openjfx:javafx-graphics:11:${platform}"
    compile "org.openjfx:javafx-controls:11:${platform}"
    compile "org.openjfx:javafx-fxml:11:${platform}"
    compile 'javax.annotation:javax.annotation-api:1.3.2'
  6. Launch the application by invoking gradle run.

Deployment

Neither Maven nor Gradle have an answer to packaging an application with the javapackager for now, as it has been removed from Oracle JDK 11 and it's not distributed with JavaFX 11. This being said Gluon is working on a temporary solution until JDK-8200758 is resolved

Liked it? Take a second to support aalmiray on Patreon!
Become a patron at Patreon!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

ˆ Back To Top