根据the Kotlin docs,有一个Kotlin标准库的OSGi bundle 包。但是,如果我按照建议用此 bundle 包替换kotlin-stdlib,则:

<dependency>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-osgi-bundle</artifactId>
    <version>${kotlin.version}</version>
    <type>bundle</type>
</dependency>

IntelliJ不再能够从stdlib中找到任何类或函数(即println):

intellij-idea - IntelliJ无法解析捆绑中的Kotlin stdlib成员-LMLPHP

如果我构建并运行该项目(使用maven-pax-plugin),则一切工作正常-似乎已经破坏了IntelliJ的分析功能。

我应该如何适当地将Kotlin包含为OSGi依赖项?

我正在使用maven-bundle-plugin构建此 bundle 包。

最佳答案

如果删除类型部分,则它应该起作用:

<type>bundle</type>

Kotlin OSGi bundle 软件不是Maven bundle 软件 Artifact

对于Intellij IDEA 2018.2,可以通过以下方式为我工作:
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-osgi-bundle</artifactId>
        <version>${kotlin.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib-jdk8</artifactId>
        <version>${kotlin.version}</version>
    </dependency>

关于intellij-idea - IntelliJ无法解析捆绑中的Kotlin stdlib成员,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52541790/

10-10 19:39
查看更多