简体   繁体   English

IntelliJ 中混合 Java/Kotlin 多模块项目中未解决的 Kotlin 参考

[英]Unresolved Kotlin reference in mixed Java/Kotlin multimodule project in IntelliJ

As title.如题。 gradle build works in command line. gradle build在命令行中工作。 All tests pass.所有测试通过。 However, in IntelliJ I get unresolved reference for things like listOf() , setOf() , coerceAtMost() , etc. Basically some Kotlin native library functions.但是,在 IntelliJ 中,我得到了unresolved reference ,例如listOf()setOf()coerceAtMost()等。基本上是一些 Kotlin 本机库函数。

My IntelliJ Kotlin plugin version is 1.3.72, and I force 1.3.72 in the build.gradle files.我的 IntelliJ Kotlin 插件版本是 1.3.72,我在 build.gradle 文件中强制使用 1.3.72。 My IntelliJ version is 2020.2.我的 IntelliJ 版本是 2020.2。 I've done "Invalidate Caches/Restart" multiple times.我已经多次完成“使缓存无效/重新启动”。

My project structure is as follows:我的项目结构如下:

root
-- build.gradle
-- settings.gradle
-- server-root
  -- server-base
    -- src/main/java
    -- src/main/kotlin
    -- test/java
    -- test/kotlin
    -- build.gradle
  -- server-module-1
    // empty for now
  -- server-module-2
    // empty for now

My base root/settings.gradle我的基本root/settings.gradle

...
include(":server-base")
...
project(":server-base").projectDir = file('server-root/server-base')

My base root/build.gradle我的基础root/build.gradle

plugins {
    id "io.freefair.lombok" version "5.2.1" apply false
    id "org.jetbrains.kotlin.jvm" version "1.3.72" apply false
    id "nebula.lint" version "16.9.0"
    id 'idea'
}

allprojects {
    repositories {
        mavenCentral()
    }
}

My server-root/server-base/build.gradle :我的server-root/server-base/build.gradle

plugins {
    id 'java'
    id "io.freefair.lombok"
    id "org.jetbrains.kotlin.jvm"
}

dependencies {
    implementation project(:'server-module-1')
    ...
}

I've tried basically every StackOverflow solution I could find and still IntelliJ gives me this issue.我基本上已经尝试了我能找到的所有 StackOverflow 解决方案,但 IntelliJ 仍然给我这个问题。 Any suggestions?有什么建议么?

I updated the Kotlin plugin to the latest: 203-1.4.21-release-IJ6682.9.我将 Kotlin 插件更新到最新版本:203-1.4.21-release-IJ6682.9。 (Using the IntelliJ updater, not manual download). (使用 IntelliJ 更新程序,而不是手动下载)。 And my IntelliJ version to 2020.3.而我的 IntelliJ 版本为 2020.3。

So even though the Kotlin plugin version doesn't the Kotlin version Gradle is setting, it works..因此,即使 Kotlin 插件版本不是 Kotlin 版本 Gradle 正在设置,它仍然有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM