gpt4 book ai didi

gradle - 打包 tornadofx 应用程序时出现不受支持的 major.minor 版本错误

转载 作者:行者123 更新时间:2023-12-03 05:05:01 24 4
gpt4 key购买 nike

几个月来,我一直在开发 Tornadofx 应用程序。它在 IDE 中运行良好(intellij Ultimate,win 10),但现在我需要创建一个实际的可执行 jar 供其他人运行它,我似乎无法让它工作。

我正在使用 openfx gradle 插件来自动收集 javafx 依赖项并提供我在开发期间一直在使用的应用程序/运行任务。那里的文档还包含 org.beryx.jlink 作为最终打包过程的插件。这是一个 tornadofx 应用程序,我用 Kotlin 编写了整个东西。我现在遇到的问题是,当我运行 jlink、jlinkZip 或 jpackage 任务(我假设它们会为我提供可分发的构建)时,我收到错误“不支持的 major.minor 版本 56.0”。

我做了一些挖掘,想,“也许我需要将我的 jdk 从 12 更新到 14”,所以我安装了 openjdk14,现在错误是“不支持的 major.minor 版本 58.0”。所以,显然问题是我的 jdk 太更新了......?我不知道。但是,我不知道构建它需要什么版本的 jdk。我只是不确定从这里去哪里。我所做的其他一些研究表明 jlink 不适用于 kotlin,但 'org.beryx.jlink' gradle 插件是“Badass jlink”并且可以与 Kotlin 一起使用。

对于进一步的背景,我有多个子模块和一个单独构建的内部核心库,因此需要构建和组合很多部分。但是,每个子模块 build.gradle 看起来像这样:

apply from: "$rootDir/kotlin-module.gradle"
apply from: "$rootDir/local-repositories.gradle" // helps resolve the local version of the core module.

dependencies {
implementation "<--anonymized core module-->"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3"
testImplementation 'io.cucumber:cucumber-java8:5.5.0'
testImplementation 'io.cucumber:cucumber-junit:5.5.0'

implementation project(":application")
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.61"
}

configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}

task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'pretty', '--add-plugin', 'html:build/cucumber/html-report', '--glue', '<-- root package name -->', 'src/test/resources/features', '--strict']
}
}
}

而 kotlin-module.gradle 文件看起来像这样:
apply plugin: 'kotlin'

group '<-- anonymized group name -->'
version '0.1.0'

repositories {
mavenCentral()
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.6.0'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
}

compileKotlin {
kotlinOptions.jvmTarget = "13" // version issue here?
}
compileTestKotlin {
kotlinOptions.jvmTarget = "13" // version issue here?
}

test {
useJUnitPlatform()
}

包含 javafx 和 tornadofx 的实际子模块如下所示:
plugins {
id 'java'
id 'application'
id 'org.jetbrains.kotlin.jvm'
id 'org.openjfx.javafxplugin' version '0.0.8'
id 'org.beryx.jlink' version '2.12.0'
id 'edu.sc.seis.launch4j' version '2.4.6'
id 'no.tornado.fxlauncher' version '1.0.20'
}

apply from: "$rootDir/kotlin-module.gradle"
apply from: "$rootDir/local-repositories.gradle"

repositories {
jcenter()
}

dependencies {
implementation "<--anonymized core module-->"

implementation project(":application")
implementation project(":data")
implementation project(":gui")
implementation "no.tornado:tornadofx:1.7.19"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-javafx:1.3.3"
testImplementation 'io.cucumber:cucumber-java8:5.5.0'
testImplementation 'io.cucumber:cucumber-junit:5.5.0'

implementation "de.jensd:fontawesomefx-commons:11.0"
implementation "de.jensd:fontawesomefx-controls:11.0"
implementation "de.jensd:fontawesomefx-fontawesome:4.7.0-11"
implementation "de.jensd:fontawesomefx-materialicons:2.2.0-11"
implementation "de.jensd:fontawesomefx-emojione:2.2.7-11"
}

javafx {
version = "14"
modules = [ 'javafx.controls', 'javafx.fxml'/*, 'javafx.web', 'javafx.swing'*/ ]
}

jlink {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = '<-- name of root module -->'
}
}

mainClassName = '<-- package.path.to.kotlin.class.extending.tornadofx.Application -->'

launch4j {
mainClassName = '<-- package.path.to.kotlin.class.extending.tornadofx.Application -->'
}

configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}

task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'pretty', '--glue', '<-- root package name -->', 'src/test/resources/features', '--strict']
}
}
}

最后,父 build.gradle 文件:
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.70'
}

group '<-- anonymized group name -->'
version '0.1.0'

repositories {
mavenCentral()
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"

testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.6.0'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
}

compileKotlin {
kotlinOptions.jvmTarget = "13" // version issue here?
}
compileTestKotlin {
kotlinOptions.jvmTarget = "13" // version issue here?
}

test {
useJUnitPlatform()
}

我真的希望有人能深入了解我还能做些什么来构建它。这对我来说真的很困惑,因为我一直在构建它并在 IDE 中运行它,这一直没有问题。

最佳答案

Gradle 6.3 是最新版本(截至此评论),也是第一个支持 Java 14 的版本。只需升级您的 Gradle 包装器:

./gradlew wrapper --gradle-version=6.3

https://docs.gradle.org/6.3/release-notes.html

关于gradle - 打包 tornadofx 应用程序时出现不受支持的 major.minor 版本错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60940973/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com