[英]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.