Gradle编译在Linux上找不到tornadofx
我想用gradle编译一个kotlin应用程序。 该应用程序使用tornadofx(javafx的kotlin版本)。
在build.gradle
,我有:
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile 'no.tornado:tornadofx:1.7.8' compile 'com.squareup.moshi:moshi:1.5.0' compile 'com.squareup.moshi:moshi-kotlin:1.5.0' // Required for local unit tests (JUnit 4 framework) testCompile 'junit:junit:4.12' }
在MyApp.kt
我有:
import javafx.application.Application import tornadofx.App
当我在Windows 10上编译这个项目时,无论是使用gradle clean build
还是.\gradlew clean build
,它都能编译并完美工作。
当我在Ubuntu Linux上编译这个项目时,我得到一个错误消息页面,其中包括:
... e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath: class tornadofx.UIComponent, unresolved supertypes: javafx.event.EventTarget class tornadofx.App, unresolved supertypes: javafx.application.Application ... e: /home/al/project/app/src/pcUi/MyApp.kt: (3, 8): Unresolved reference: javafx e: /home/al/project/app/src/pcUi/MyApp.kt: (12, 5): Unresolved reference: Application ...
虽然如果我从一个干净的设置做到这一点,gradle输出还包括:
Download https://jcenter.bintray.com/no/tornado/tornadofx/1.7.8/tornadofx-1.7.8.pom Download https://jcenter.bintray.com/com/squareup/moshi/moshi/1.5.0/moshi-1.5.0.pom Download https://jcenter.bintray.com/com/squareup/moshi/moshi-parent/1.5.0/moshi-parent-1.5.0.pom Download https://jcenter.bintray.com/com/squareup/moshi/moshi-kotlin/1.5.0/moshi-kotlin-1.5.0.pom Download https://jcenter.bintray.com/org/glassfish/javax.json/1.0.4/javax.json-1.0.4.pom Download https://jcenter.bintray.com/org/glassfish/json/1.0.4/json-1.0.4.pom Download https://jcenter.bintray.com/net/java/jvnet-parent/3/jvnet-parent-3.pom Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.1.3/kotlin-stdlib-jre8-1.1.3.pom Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.1.3/kotlin-reflect-1.1.3.pom Download https://jcenter.bintray.com/com/squareup/okio/okio/1.13.0/okio-1.13.0.pom Download https://jcenter.bintray.com/com/squareup/okio/okio-parent/1.13.0/okio-parent-1.13.0.pom Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre7/1.1.3/kotlin-stdlib-jre7-1.1.3.pom Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.3/kotlin-stdlib-1.1.3.pom Download https://jcenter.bintray.com/no/tornado/tornadofx/1.7.8/tornadofx-1.7.8.jar Download https://jcenter.bintray.com/com/squareup/moshi/moshi/1.5.0/moshi-1.5.0.jar Download https://jcenter.bintray.com/com/squareup/moshi/moshi-kotlin/1.5.0/moshi-kotlin-1.5.0.jar Download https://jcenter.bintray.com/org/glassfish/javax.json/1.0.4/javax.json-1.0.4.jar Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.1.3/kotlin-stdlib-jre8-1.1.3.jar Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.1.3/kotlin-reflect-1.1.3.jar Download https://jcenter.bintray.com/com/squareup/okio/okio/1.13.0/okio-1.13.0.jar Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre7/1.1.3/kotlin-stdlib-jre7-1.1.3.jar Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.3/kotlin-stdlib-1.1.3.jar
这对我来说没有任何意义,因为它正确地下载了依赖关系(在Linux和Windows上),但是只能在Windows而不是Linux上成功编译。 我一直无法弄清楚发生了什么,所以任何人都可以提供任何建议,看看在哪里?
看到错误信息:
e: /home/al/project/app/src/pcUi/MyApp.kt: (3, 8): Unresolved reference: javafx e: /home/al/project/app/src/pcUi/MyApp.kt: (12, 5): Unresolved reference: Application
看起来你没有在Ubuntu上正确设置JDK。 JavaFX不再是OpenJDK的一部分,你必须手动安装它: https : //packages.qa.debian.org/o/openjfx.html 。
编辑:请参阅https://stackoverflow.com/a/43301246/4697327 。 您可能正在使用包含JavaFX的Windows上的Oracle JDK。
- 在eclipse上通过gradle设置Kotlin
- Kotlin:Gradle增量编译
- 使用Gradle构建Kotlin项目有时会导致NoClassDefFoundError失败
- 无法让dokka在gradle / android项目上生成kotlin文档
- 在多个“编译…”任务之前连接一个generateSrc gradle任务
- 将Groovy gradle移植到Kotlin gradle(ext缺少或闭包转换,不确定)
- IntelliJ运行vs运行jar,带有Social Oauth2的Springboot Kotlin,Multi模块Gradle项目
- Gradle同步失败:无法GET'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.3-2/kotlin-gradle-plugin-1.1.3-2.pom'
- Kotlin测试失败从命令行与ClassNotFoundException但从IntelliJ工作