簡體   English   中英

在 Intellij IDEA 生成的 kotlin 原生項目中放置 gradle 依賴項塊的位置?

[英]Where to put gradle dependencies block in kotlin native project generated by Intellij IDEA?

我正在嘗試使用 Kotlin Native 制作我的第一個應用程序。 我想將 TornadoFX 添加到我新創建的項目中。 我需要根據TornadoFX 指南添加依賴

dependencies {
    compile 'no.tornado:tornadofx:x.y.z'
}

問題是 - 我不知道我到底把它放在哪里

這是我的 build.gradle 內容(由 IntelliJ IDEA 生成):

plugins {
    id 'org.jetbrains.kotlin.multiplatform' version '1.3.60'
}
repositories {
    mavenCentral()
}
kotlin {
    // For ARM, should be changed to iosArm32 or iosArm64
    // For Linux, should be changed to e.g. linuxX64
    // For MacOS, should be changed to e.g. macosX64
    // For Windows, should be changed to e.g. mingwX64
    mingwX64("mingw") {
        binaries {
            executable {
                // Change to specify fully qualified name of your application's entry point:
               entryPoint = 'sample.main'
                // Specify command-line arguments, if necessary:
                runTask?.args('')
            }
        }
    }
    sourceSets {
        // Note: To enable common source sets please comment out 'kotlin.import.noCommonSourceSets' property
        // in gradle.properties file and re-import your project in IDE.
        mingwMain {
        }
        mingwTest {
        }
    }
}

// Use the following Gradle tasks to run your application:
// :runReleaseExecutableMingw - without debug symbols
// :runDebugExecutableMingw - with debug symbols

我嘗試過的地方:

1. 頂級

> Could not find method compile() for arguments [no.tornado:tornadofx:1.7.19] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

2. kotlin 內部{}

> Could not find method compile() for arguments [no.tornado:tornadofx:1.7.19] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

3. mingwMain內部{}

> Could not find method compile() for arguments [no.tornado:tornadofx:1.7.19] on object of type org.jetbrains.kotlin.gradle.plugin.mpp.DefaultKotlinDependencyHandler.

此外,當放入 mingwMain 時,編譯行會突出顯示,並顯示'compile' cannot be applied to '(java.lang.String)'

對於 Kotlin 多平台插件,依賴塊應該進入每個源集。 但是,沒有稱為compile類型。 相反,您可以使用implementation或您可以在文檔中閱讀的其他類型之一。

例子:

sourceSets {
    mingwMain {
        dependencies {
            implementation 'no.tornado:tornadofx:x.y.z'
        }
    }
}

順便說一句,如果您正在編寫 Kotlin 項目,為什么要使用 Groovy DSL 而不是 Kotlin DSL? :-)

如此評論所指出的,我們不能在 Kotlin Native 中使用 TornadoFX,所以從一開始我就做錯了所有事情,這並不是一個真正的 gradle 問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM