2017-08-08 80 views
1

我想用gradle編譯一個kotlin應用程序。該應用程序使用tornadofx(javafx的kotlin版本)。Gradle編譯在Linux上找不到tornadofx

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上編譯。我一直無法弄清楚發生了什麼,所以任何人都可以提供任何建議,看看哪裏?

+0

假設您使用OpenJDK,默認情況下JavaFX不包含在Oracle JDK中,因此您可能需要安裝它或切換到Oracle。 –

+3

如果你在Ubuntu上,它就像'sudo apt-get install openjfx'一樣簡單。 –

回答

2

看到錯誤消息:

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

好像你沒有你的JDK正確設置在Ubuntu做。 JavaFX不再是OpenJDK的一部分,您必須手動安裝它:https://packages.qa.debian.org/o/openjfx.html

編輯:見https://stackoverflow.com/a/43301246/4697327。您可能在Windows上使用了Oracle JDK,其中包含JavaFX。

+0

輝煌,謝謝。我認爲我一直在研究這個錯誤的假設,即Gradle正在下載所有必需的東西(包括javafx),但顯然它只是獲得了tornadofx附加組件。在Linux上安裝openjfx將其整理出來。 – DrAl