I am pretty new to gradle and unfamiliar with the Groovy language/build script syntax etc.
I have one main Class, which starts perfectly fine with
gradle run
But I now want to create a new Task (uitest), which should be called with something like:
gradle -q uitest
which should run like above, but with another mainClass.
My build script so far looks like this:
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.8'
}
mainClassName = 'streetsim.ui.StreetSimApp'
javafx {
version = "11.0.2"
modules = ['javafx.controls', 'javafx.fxml']
}
task uitest(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'streetsim.ui.TemporaryUITestPool.main'
}
group 'groupname'
version '1.0-SNAPSHOT'
sourceCompatibility = 11
repositories {
jcenter()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
}
test {
useJUnitPlatform()
}
EDIT: I changed the task as following:
task uitest(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'streetsim.ui.TemporaryUITestPool'
}
And now I get following error:
Error: JavaFX runtime components are missing, and are required to run this application
As mentioned in the comment to another answer below, I do not want to add VM arguments if possible as I do not want to require a local JavaFX installation
because this FX below are required you need to add the following to the java command (and remove.main as per comment above)
--add-modules javafx.controls,javafx.fxml --module-path <path_to_modules>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.