This plugin is used to manage and configure a JavaFX project quickly and reliably. In addition to supporting cross-platform compilation from the current platform.
cjfx-version = 1.1.0
It is currently only available for the Gradle build system. In order to use it, you must define the plugin within the project as follows:
Groovy DSL
plugins {
id "io.github.uoxx3.cjfx" version "{cjfx-version}"
}
Kotlin DSL
plugins {
id("io.github.uoxx3.cjfx") version "{cjfx-version}"
}
There are several ways to configure the plugin. The easiest way to do it is through the extension inside the "build.gradle" or "build.gradle.kts" file.
Groovy DSL
// Groovy & Kotlin DSL
Cjfx {
version.set(/* Target JavaFX version */)
platform.set(/* Target compilation platform */)
architecture.set(/* Target compilation architecture */)
modules.addAll(/* All javafx modules used */)
dependencyConfigurations.addAll(/* All configurations where modules are used */)
}
Cjfx accepts both specific versions and dynamic versions. These dynamic versions are identified as they contain the '#' characters.
Custom version
// Groovy & Kotlin DSL
Cjfx {
version.set("21")
}
Dynamic versions
// Groovy & Kotlin DSL
Cjfx {
version.set("#latest#") // Get the latest stable version of JavaFX
}
// Groovy & Kotlin DSL
Cjfx {
version.set("#early#") // Get the latest early access version of JavaFX
}
// Groovy & Kotlin DSL
Cjfx {
version.set("#ea\\+\\d#") // You can also use regular expressions to determine the JavaFX version.
}
Platforms
By default, the plugin determines the current platform where the project is executed, but it is possible to specify the platform.
// Groovy & Kotlin DSL
Cjfx {
platform.set(Uplatform.LINUX)
}
Architecture
By default, the plugin determines the current architecture where the project is executed, but it is possible to specify the architecture.
// Groovy & Kotlin DSL
Cjfx {
architecture.set(UArchitecture.ARM)
}
Modules
By default, the plugin only includes the JavaFX Base
module, and you need to specify the necessary modules.
// Groovy DSL
import uoxx3.cjfx.CjfxModule
Cjfx {
var targetModules = [CjfxModule.CONTROLS, CjfxModule.FXML]
modules.addAll(targetModules)
}
// Kotlin DSL
import uoxx3.cjfx.CjfxModule
Cjfx {
val targetModules = listOf(CjfxModule.CONTROLS, CjfxModule.FXML)
modules.addAll(targetModules)
}
If all modules are required, you can use the special option CjfxModule.ALL
that uses all JavaFX modules.
CjfxModule.ALL == CjfxModule.[BASE, GRAPHICS, CONTROLS, FXML, MEDIA, SWING, WEB]
Dependency configurations
The dependency configuration determines where and how the JavaFX application or library will be compiled. By default, the plugin will assume that you are implementing the modules, but you can change this behavior easily:
// Groovy DSL
Cjfx {
var configurations = ["compileOnly", "testCompileOnly"]
dependencyConfiguration.clear()
dependencyConfiguration.addAll(configurations)
}
// Kotlin DSL
Cjfx {
val configurations = listOf("compileOnly", "testCompileOnly")
dependencyConfiguration.clear()
dependencyConfiguration.addAll(configurations)
}
It can also be configured through the gradle.properties
or cjfx.properties
files as follows:
cjfx.configuration.version=#latest#
cjfx.configuration.platform=linux
cjfx.configuration.architecture=ARM
cjfx.configuration.modules=controls; graphics; fxml
cjfx.configuration.dependencyConfiguration=compileOnly; testCompileOnly; runtimeOnly