[英]Gradle build fail: Process 'Gradle Test Executor 1' finished with non-zero exit value 1
[英]Gradle test executor failing with non-zero exit value 1 (IntelliJ Idea default Gradle[7.4.1]/JavaFX[17.0.1] build)
使用 JavaFX 和 Gradle 构建工具创建应用程序:
在 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
我尝试增加堆大小并将项目克隆到另一个位置。 我还浏览了gradle docs和gradle github并没有找到任何特别有用的东西。
此外,我还阅读了IntelliJ 设置和配置教程以及JavaFX 教程,但我似乎找不到任何关于结构或依赖项或与单元测试相关的任何其他内容。 我在下面包含了其他代码信息。 (不包括完整示例,因为我发现了问题)
├───.gradle
└───src
├───main
│ └───java
│ └───com
│ └───example
│ └───testingtesting
└───test
└───java
└───!!JUnitTestingFile!!
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'
}
原来我错过了目录结构中的一些内容,因为我在这个精彩的教程及其相应的 git repo中发现了这一点。
对我来说问题出在目录结构中,应该如下:
├───.gradle
└───src
├───main
│ └───java
│ └───com
│ └───example
│ └───testingtesting
└───test
└───java
└───com
└───junit5
└───!!JUnitTestingFile!!
(注意添加了tests.java.com.junit5文件夹,而不仅仅是tests.java文件夹)
我不会声称完全理解为什么目录结构会导致错误,所以如果有人对为什么会发生这种情况有更多的了解,请分享。
我还检查了给定的 gradle 构建文件是否继续使用新的构建结构,尽管它与示例项目的依赖关系略有不同,并且确实如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.