Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oliver-loeffler/javafxmodularspidemo
How to setup a modular Maven build for a JavaFX project and how to create a runtime image including SPI modules (e.g. JDBC drivers).
https://github.com/oliver-loeffler/javafxmodularspidemo
javafx jlink maven modules runtime-image spc
Last synced: 10 days ago
JSON representation
How to setup a modular Maven build for a JavaFX project and how to create a runtime image including SPI modules (e.g. JDBC drivers).
- Host: GitHub
- URL: https://github.com/oliver-loeffler/javafxmodularspidemo
- Owner: Oliver-Loeffler
- Created: 2021-03-14T22:48:15.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-14T23:56:19.000Z (almost 4 years ago)
- Last Synced: 2024-11-19T21:34:03.164Z (2 months ago)
- Topics: javafx, jlink, maven, modules, runtime-image, spc
- Language: Java
- Homepage:
- Size: 24.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Demo how to create JavaFX app with custom runtime image using SPI drivers such as JDBC drivers
The only purpose of this project is to investigate, how to properly configure a JavaFX project
using Maven and the JavaFX Maven plugin. The interesting point is, how to properly link JDBC
drivers in a customized runtime?![DemoApp](DemoAppView2.png)
## Boundary conditions
* JavaFX 15
* modular project, so all classes moved to module path
* Maven as build tool
* Javafx-maven-plugin
* Uses some SPI modules from: Microsoft SqlServer JDBC driver, MariaDB JDBC driver and PostgreSQL JDBC driver## Problem
When running the POM.XML without explicit configuration of `--module-path` in `javafx-maven-plugin`,
the JDBC drivers are not found when running the image built using `mvn javafx:jlink`. On the other hand
when executing `mvn javafx:run`, everything works as expected, the JDBC drivers are detected.## Doesnt work as expected when using `mvn javafx:jlink`:
```XML
org.openjfx
javafx-maven-plugin
0.0.5
true
2
true
true
demoapp
hello
hellozip
net.raumzeitfalle.demoapp/playground.javafx.ModularSpiDemo
MODULEPATH
```
## Works! Yay!
As a workaround, one can use the `maven-dependency-plugin` to copy all dependencies to a certain location.
So when before JLink is called, a copy task is executed and later Jlink can use the specified directory
as module path.```XML
org.openjfx
javafx-maven-plugin
0.0.5
true
2
true
true
demoapp
hello
hellozip
net.raumzeitfalle.demoapp/playground.javafx.ModularSpiDemo
MODULEPATH
--module-path
${project.build.directory}/modulepath
org.apache.maven.plugins
maven-dependency-plugin
3.1.2
copy-dependencies
prepare-package
copy-dependencies
${project.build.directory}/modulepath
false
false
true
```
## How to run the project
```cmd
> mvn javafx:run
```
## How to create a runtime-image
The resulting runtime image won't be able to detect any JDBC drivers.
```cmd
> mvn javafx:jlink
```
Alternatively, one could run the following line. The resulting runtime image will detect the JDBC drivers.
```cmd
> mvn package javafx:jlink
```
Well, somehoe this does not feel correct yet, but certainly I'll have to do more work to gain better
understanding of what Maven does here. It becomes possibly helpful but definitively interesting,
when running the Maven process with an increased verbosity.```cmd
> mvn -X package javafx:jlink```
## Executing the runtime-image
The runtime image can be started then using:
```cmd
> target\ModularSpiDemo\bin\Demo.bat
```
![How it loogs like](DemoAppView2.png)