I'm trying to run a sample JavaFX app on Mac OS.
build.gradle
apply plugin: 'java'
apply plugin: 'application'
repositories {
    mavenCentral()
}
dependencies {
    compile "org.openjfx:javafx-base:11"
    compile "org.openjfx:javafx-graphics:11"
    compile "org.openjfx:javafx-controls:11"
}
compileJava {
    doFirst {
        println "CLASSPATH IS $classpath.asPath"
        options.compilerArgs = [
                '--module-path', classpath.asPath,
                '--add-modules', 'javafx.graphics'
        ]
        classpath = files()
    }
}
Java class
package com.test;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class HelloFX extends Application {
    @Override
    public void start(Stage stage) {
        String javaVersion = System.getProperty("java.version");
        String javafxVersion = System.getProperty("javafx.version");
        Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
        Scene scene = new Scene(l, 640, 480);
        stage.setScene(scene);
        stage.show();
    }
    public static void main(String[] args) {
        launch();
    }
}
I use Gradle 4.10.2
Executing task 'gradle compileJava' I'm getting this error:
> Task :compileJava FAILED
CLASSPATH IS /Users/dragos.pruteanu/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-controls/11/58d961774262ec972bf304e16c154a8e18c2050b/javafx-controls-11.jar:/Users/dragos.pruteanu/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-graphics/11/a736dd079047ec0b72b8c4970842a5c5e0c19f2f/javafx-graphics-11.jar:/Users/dragos.pruteanu/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-base/11/9fcd3e8e3227ec97bf503f7991fad1f3b14d005/javafx-base-11.jar
error: module not found: javafx.graphics
1 error
What is wrong? For some reason the JavaFX libraries are not loaded correctly. Could be the error from MacOS or OpenJFX?
 
     
    