Working on creating an application with JavaFX and the Gradle build tool:
- JavaFX: 17.0.1
- Gradle: 7.3.1
- Java: Amazon Coretto 17.0.3
- JUnit: 5.8.2
I encountered the following error while running unit tests in Junit
> Task :test FAILED
Error occurred during initialization of boot layer
java.lang.RuntimeException: Unable to parse --add-opens <module>/<package>: com.example.testingtesting/
Execution failed for task ':test'.
> Process 'Gradle Test Executor 2' finished with non-zero exit value 1
I have tried increasing my heap size and cloning the project to another location. I have also gone through the gradle docs and the gradle github and have not been able to find anything of particular use.
In addition I have also gone through the IntelliJ setup and configuration tutorials and the JavaFX tutorials but I cannot seem to find anything on the structure or dependencies or anything else relating to the unit tests. I have included additional code information below. (not including the full example because I found the problem)
Directory structure is as follows:
├───.gradle
└───src
├───main
│ └───java
│ └───com
│ └───example
│ └───testingtesting
└───test
└───java
└───!!JUnitTestingFile!!
Gradle Build Script
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.10'
id 'org.beryx.jlink' version '2.24.1'
}
group 'com.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
ext {
junitVersion = '5.8.2'
}
sourceCompatibility = '17'
targetCompatibility = '17'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
application {
mainModule = 'com.example.testingtesting'
mainClass = 'com.example.testingtesting.HelloApplication'
}
javafx {
version = '17.0.1'
modules = ['javafx.controls', 'javafx.fxml']
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}
test {
useJUnitPlatform()
}
jlink {
imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip")
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'app'
}
}
jlinkZip {
group = 'distribution'
}