[英]How to add a dependency in a multiplatform kotlin / native intellij project?
I have the following build.gradle configuration:我有以下 build.gradle 配置:
plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.3.41'
}
repositories {
mavenCentral()
}
kotlin {
linuxX64("linux") {
binaries {
executable {
entryPoint = 'sample.main'
runTask?.args('')
}
}
}
sourceSets {
linuxMain {
dependencies {
api("org.http4k:http4k-core:3.183.0")
}
}
linuxTest {
}
}
}
And the following source file src/linuxMain/kotlin/sample/SampleLinux.kt
:以及以下源文件
src/linuxMain/kotlin/sample/SampleLinux.kt
:
package sample
fun hello(): String = "Hello, Kotlin/Native!"
fun main() {
println(hello())
}
How to add a external library in order to be able to use autocomplete in imports for the library org.http4k:http4k-core:3.183.0
?如何添加外部库以便能够在库
org.http4k:http4k-core:3.183.0
的导入中使用自动完成功能?
As you can see, I tried to add the line api("org.http4k:http4k-core:3.183.0")
in linuxMain dependencies, but although intellij show the library in External Libraries section, I cannot work with the packages neither classes of http4k in SampleLinux.kt
file: any org.http4k.....
import attempt is not recognized and generates compilation error.如您所见,我尝试在 linuxMain 依赖项中添加行
api("org.http4k:http4k-core:3.183.0")
,但是尽管 intellij 在 External Libraries 部分中显示了该库,但我无法使用包和类SampleLinux.kt
文件中的 http4k:任何org.http4k.....
导入尝试都无法识别并生成编译错误。
After a quick look, I am almost sure that http4k
is JVM-only library, at least for now.快速浏览后,我几乎可以肯定
http4k
是 JVM-only 库,至少现在是这样。 According to this issue , they are still waiting for Native to grow.根据这个问题,他们还在等待 Native 成长。 If you are interested, it would be nice if one can ask the library maintainers again.
如果您有兴趣,可以再次询问库维护人员会很好。 As far as K/N has grown a lot by the last year, maybe they change their mind.
至于 K/N 到去年增长了很多,也许他们改变了主意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.