简体   繁体   English

如何在多平台 kotlin / native intellij 项目中添加依赖项?

[英]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.

相关问题 如何使用 Gradle 和 IntelliJ 在 Kotlin 多平台项目中配置 JUnit 5? - How to configure JUnit 5 in a Kotlin multiplatform project using Gradle and IntelliJ? 如何为 kotlin-multiplatform (kotlin 1.3.50) 添加对 build.gradle.kts 的依赖项? - How to add a dependency to build.gradle.kts for kotlin-multiplatform (kotlin 1.3.50)? IntelliJ上的Kotlin Multiplatform每次尝试下载本机依赖项 - Kotlin Multiplatform on IntelliJ is trying to download native dependencies every time Gradle、Kotlin:如何在 intellij 中添加另一个 Spring Boot 项目作为模块依赖项 - Gradle, Kotlin : How to add another spring boot project as a module dependency in intellij IntelliJ Kotlin多平台项目Gradle同步时间很长 - IntelliJ Kotlin multiplatform project Gradle sync very long Intellij 为 Kotlin 多平台生成的项目始终显示构建失败 - Intellij generated Project for Kotlin Multiplatform always show build failed 如何在 Kotlin/Multiplatform 项目中使用 .klib 库 - How to use .klib library in Kotlin/Multiplatform project 如何使用单个build.gradle配置向Kotlin多平台项目添加依赖项 - How to add dependency to kotlin multiplatform projects with single build.gradle configuration 如何将项目依赖项添加到由 `kotlin-multiplatform` 插件创建的特定平台目标? - How to add project dependencies to specific platform targets created by the `kotlin-multiplatform` plugin? 如何使 Kotlin Multiplatform 与 Android Studio 的项目视图一起使用? - How to make Kotlin Multiplatform work with Android Studio's project view?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM