Simplifies working with JavaFX 11+ for gradle projects.
To use the plugin, apply the following two steps:
plugins
DSL:Groovy
plugins {
id 'org.openjfx.javafxplugin' version '0.0.14'
}
Kotlin
plugins {
id("org.openjfx.javafxplugin") version "0.0.14"
}
buildscript
DSL:Groovy
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'org.openjfx:javafx-plugin:0.0.14'
}
}
apply plugin: 'org.openjfx.javafxplugin'
Kotlin
buildscript {
repositories {
maven {
setUrl("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("org.openjfx:javafx-plugin:0.0.14")
}
}
apply(plugin = "org.openjfx.javafxplugin")
Specify all the JavaFX modules that your project uses:
Groovy
javafx {
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
Kotlin
javafx {
modules("javafx.controls", "javafx.fxml")
}
To override the default JavaFX version, a version string can be declared. This will make sure that all the modules belong to this specific version:
Groovy
javafx {
version = '17'
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
Kotlin
javafx {
version = "17"
modules("javafx.controls", "javafx.fxml")
}
The plugin will include JavaFX dependencies for the current platform. However, a different target platform can also be specified.
Supported targets are:
Groovy
javafx {
modules = [ 'javafx.controls', 'javafx.fxml' ]
platform = 'mac'
}
Kotlin
javafx {
modules("javafx.controls", "javafx.fxml")
platform = 'mac'
}
JavaFX application require native binaries for each platform to run. By default, the plugin will include these binaries for the target platform. Native dependencies can be avoided by declaring the dependency configuration as compileOnly.
Groovy
javafx {
modules = [ 'javafx.controls', 'javafx.fxml' ]
configuration = 'compileOnly'
}
Kotlin
javafx {
modules("javafx.controls", "javafx.fxml")
configuration = "compileOnly"
}
Multiple configurations can also be targeted by using configurations
.
For example, JavaFX dependencies can be added to both implementation
and testImplementation
.
Groovy
javafx {
modules = [ 'javafx.controls', 'javafx.fxml' ]
configurations = [ 'implementation', 'testImplementation' ]
}
Kotlin
javafx {
modules("javafx.controls", "javafx.fxml")
configurations("implementation", "testImplementation")
}
By default, JavaFX modules are retrieved from Maven Central. However, a local JavaFX SDK can be used instead, for instance in the case of a custom build of OpenJFX.
Setting a valid path to the local JavaFX SDK will take precedence:
Groovy
javafx {
sdk = '/path/to/javafx-sdk'
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
Kotlin
javafx {
sdk = "/path/to/javafx-sdk"
modules("javafx.controls", "javafx.fxml")
}
Issues can be reported to the Issue tracker.
Contributions can be submitted via Pull requests, providing you have signed the Gluon Individual Contributor License Agreement (CLA).
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。