The Gluon Client plugin for maven projects leverages GraalVM, OpenJDK and JavaFX 11+, by compiling into native code the Java Client application and all its required dependencies, so it can directly be executed as a native application on the target platform.
To use the plugin, apply the following steps:
Edit your pom file and add the plugin:
<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>client-maven-plugin</artifactId>
<version>0.1.19</version>
<configuration>
<mainClass>your.mainClass</mainClass>
</configuration>
</plugin>
<pluginRepositories>
<pluginRepository>
<id>gluon-releases</id>
<url>https://nexus.gluonhq.com/nexus/content/repositories/releases/</url>
</pluginRepository>
</pluginRepositories>
The plugin allows some options that can be set in configuration
, to modify the default settings, and several goals, to build and run the native application.
You can run the regular goals to build and run your project as a regular Java project on the JVM, if you use the javafx-maven-plugin
plugin:
mvn clean javafx:run
Once the project is ready, the Client plugin has these main goals:
This goal does the AOT compilation. It is a very intensive and lengthy task (several minutes, depending on your project and CPU), so it should be called only when the project is ready and runs fine on a VM.
Run:
mvn client:compile
The results will be available at target/client/gvm
.
When the project is compiled for the target platform, this goal will generate the native executable.
Run:
mvn client:link
The results will be available at target/client/$targetPlatform/$AppName
.
This goal simply combines client:compile
and client:link
.
Runs the executable in the target platform.
Run:
mvn client:run
Or run directly the application from command line:
target/client/$targetPlatform/$AppName/$AppName
It will create a distributable native application.
Create a package of the executable in the target platform.
Run:
mvn client:package
For instance, on iOS, this can be used to create an IPA.
At this moment the plugin is in beta, and supports Linux, Mac OS X and iOS platforms for now.
To use the plugin to develop and deploy native applications on Mac or iOS platforms, you need a Mac with MacOS X 10.13.2 or superior, and Xcode 9.2 or superior, available from the Mac App Store. Once Xcode is downloaded and installed, open it and accept the license terms.
For now, only JDK 11 is supported. Any JDK 11 distribution that doesn't bundle JavaFX is valid, like:
Once downloaded and installed, set JAVA_HOME
pointing to that JDK 11.
Check the documentation for more details about the plugin and running the maven samples.