I\'m trying to build a relatively simple JavaFX application using Gradle. However, I have no idea how to do it.
I\'m relatively new to Gradle, and for simple (non-
The official gradle plugin for javafx is at https://github.com/openjfx/javafx-gradle-plugin.
I have successfully used this plugin from INtelliJ IDEA CE with following to illustrate my build.gradle file:
plugins {
id 'java'
id 'application'
id 'maven'
id 'maven-publish'
id 'org.openjfx.javafxplugin' version '0.0.8'
}
javafx {
// Points to JDK and its JavaFX libraries, also declares target runtime JDK
// javaRuntime = '/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk'
version = '13' // Specify javafx sdk version
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.swing', 'javafx.media', 'javafx.graphics']
sdk = System.getenv('JAVAFX_HOME')
if (sdk == null || sdk.isBlank()) {
throw new InvalidUserDataException("JAVAFX_HOME environment variable is not set. It must be set to root folder where JAVAFX SDK is located")
}
application {
def javafxHome = System.getenv('JAVAFX_HOME')
mainClassName = 'com.foo.FooApp'
applicationName = 'foo-app'
applicationDefaultJvmArgs = [
"--module-path=${javafxHome}" + File.separator + 'lib',
'--add-modules=javafx.controls,javafx.swing,javafx.media,javafx.graphics']
println("applicationDefaultJvmArgs:" + applicationDefaultJvmArgs)
}
}
dependencies {
... ommitted ...
}