openjfx / samples

JavaFX samples to run with different options and build tools
BSD 3-Clause "New" or "Revised" License
578 stars 1.52k forks source link

Sample Gradle project doesn't build a working application #31

Closed hakanai closed 5 years ago

hakanai commented 5 years ago

I'm just trying to get a simple application up and running from an actual build. I thought the project here might provide a working example, but it turns out that it builds a non-working distribution.

Reproduction:

> git clone https://github.com/openjfx/samples
> cd samples\HelloFX\Gradle\hellofx
> set JAVA_HOME="c:\Program Files\Java\jdk-11.0.3"
> gradlew distZip
> cd build\distributions
> unzip hellofx.zip
> cd hellofx\bin
> hellofx.bat

Result:

Error: JavaFX runtime components are missing, and are required to run this application

Am I doing something wrong? I was under the impression that the JavaFX jars fetched via Gradle would be the components it's supposed to be using.

jperedadnr commented 5 years ago

The usual tasks like distZip or even jar don't deal with the JavaFX dependencies unless you modify them to do so.

The JavaFX Gradle plugin helps you running the project, but it is not intended for distribution tasks.

Options:

hakanai commented 5 years ago

Huh... What's the point then, if I'm the only one who can run it. :/

Anyway, I think this is the minimum to get a working distribution out the end, using jlink as suggested. Thanks for the tip, I still think it would be nice if the samples repo had this as part of the build script.

https://github.com/trejkaz/samples/blob/master/HelloFX/Gradle/hellofx/build.gradle

(Next step is to get native compilation going, but I'm not yet sure whether that's something it can do.)

jperedadnr commented 5 years ago

As mentioned, the JavaFX gradle plugin helps you running your app, but your gradle project already relies on a set of different plugins, like Java, Application or the Modular plugin.

To help on distribution and using the jlink tool (and also the still ea jpackage tool), you can add the jlink plugin described in several places throughout the docs (gradle modular projects).

For native compilation, you may want to check the Gluon Client plugins.