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



我正在尝试在 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. 科特林内部 {}

> 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. 内部明威主{}

> 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 问题。

最新更新