gradle - 在 Intellij IDEA 生成的 kotlin 原生项目中,将 gradle 依赖项 block 放在哪里?

标签 gradle intellij-idea tornadofx kotlin-native

我正在尝试使用 Kotlin Native 制作我的第一个应用程序。我想将 TornadoFX 添加到我新创建的项目中。 我需要根据 TornadoFX guide 添加依赖项

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。顶层

> 在 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象上找不到参数 [no.tornado:tornadofx:1.7.19] 的方法 compile()。

<强>2。 kotlin 内部{}

> 在 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象上找不到参数 [no.tornado:tornadofx:1.7.19] 的方法 compile()。

<强>3。在 mingwMain{}

内部

> 在 org.jetbrains.kotlin.gradle.plugin.mpp.DefaultKotlinDependencyHandler 类型的对象上找不到参数 [no.tornado:tornadofx:1.7.19] 的方法 compile()。

此外,当放在 mingwMain 中时,编译行会突出显示一条通知 'compile' cannot be applied to '(java.lang.String)'

最佳答案

对于 Kotlin 多平台插件,依赖 block 应该进入每个源集。但是,没有名为compile 的类型。相反,您可以使用 implementation 或您可以在 documentation 中阅读的其他类型之一。 .

例子:

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

顺便说一句,如果您正在编写 Kotlin 项目,为什么要使用 Groovy DSL 而不是 Kotlin DSL? :-)

关于gradle - 在 Intellij IDEA 生成的 kotlin 原生项目中,将 gradle 依赖项 block 放在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59198442/

相关文章:

intellij-idea - intellij 2020.1 sbt mainRunner 配置

datepicker - 在 Kotlin TornadoFX 上获取日期选择器日期

kotlin - ItemViewModel 项目为空

gradle - Spring Integration 4-示例-Gradle

groovy - Gradle:创建一个在 "build"任务之后运行的任务

javascript - WebStorm,使用 Node Supervisor(所以每次代码更改后不必重新启动)?

java - 错误 :java: javacTask: source release 8 requires target release 1. 8

java - 如何在使用 gradle 的编译阶段添加依赖 jar 文件?

java - Android Studio 3.1.2 中 Gradle 同步失败

kotlin - 如何使用TornadoFx创建嵌套/拆分列标题?