I know it is possible to create a project to run a single application class using org.openjfx.javafxplugin like so:
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.1.0'
}
javafx {
version = '22.0.1'
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.web', 'javafx.swing' ]
}
application {
mainClass = 'my.App'
}
It configures the :run
task properly and adds JavaFX dependencies.
But I need to create a few tasks to run different classes. runAppA, runAppB, etc. How do I do that?
Declaring a JavaExec task like so does not help:
tasks.register('runAppA', JavaExec) {
group = 'application'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'runAppA'
jvmArgs = [
'--module-path', configurations.implementation.runtimeClasspath.asPath,
'--add-modules', 'javafx.controls,javafx.fxml,javafx.web,javafx.swing'
]
}
It gives me an error Could not get unknown property ‘runtimeClasspath’ for configuration ‘:component-demos:implementation’ of type org.gradle.api.internal.artifacts.configurations.DefaultUnlockedConfiguration.
How do I properly configure it?