gradle - 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. 在 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?:-)
推荐阅读
- google-data-studio - 如何删除 Google 数据洞察报告中的维度?
- angular - 得到错误无法读取角度中的空属性“标题”
- javascript - 如何在dropboxlist里面显示数据,使用后面代码中的静态方法来填充dropdownlist
- selenium-webdriver - python selenium 检查此文本字段是否被禁用
- python - mkdir错误文件路径在python中不存在
- verilog - 编写一个简单的函数来计算向量中的个数
- angular - 错误:找不到“Productionserver”类型的不同支持对象“[object Object]”。NgFor 仅支持绑定到 Iterables,例如 Arrays
- excel - 在嵌套循环中搜索一系列行中的 3 列
- javascript - 我在一个程序中有两个递归,对我来说一切都应该没问题,但它最后给了我错误的答案。JS
- jenkins - 在管道中使用通用 webhook 触发器变量