简体   繁体   English

Intellij gradle 同步错误:scala 导入错误

[英]Intellij gradle sync error: scala import error

I have updated my IntelliJ and the gradle sync outputs a warning which affects my IDE autocomplete.我已经更新了我的 IntelliJ,并且 gradle 同步输出了一条警告,该警告会影响我的 IDE 自动完成功能。

I have tried looking for this problem and I've tried some fixes with package versions or change from compile to implementation, but none have worked.我曾尝试寻找此问题,并尝试使用 package 版本或从编译更改为实现,但没有一个有效。 Here is my gradle part that seems to generate the error.这是我的 gradle 部分,似乎会产生错误。

allprojects {
    apply plugin: 'java'
    apply plugin: 'scala'

    group = 'com.adobe.platform.activation'
    sourceCompatibility = 1.8

    // Once we migrate to our own jenkins, this will be removed
    String gitBranch = System.getenv("GIT_BRANCH")
    if (gitBranch != null && gitBranch != "master") {
        String version = version.toString()
        int dashIndex = version.lastIndexOf('-')
        String prefix = version.substring(0, dashIndex)
        String suffix = version.substring(dashIndex + 1)
        String newVersion = "$prefix-$gitBranch-$suffix"
                .replace("/", "-")
                .replace("_", "-")

        setVersion(newVersion)
    }
}

The warning looks like this.警告看起来像这样。

Warning:<i><b>root project '....': Unable to build Scala project configuration</b>
Details: org.gradle.api.GradleException: Cannot infer Scala class path because no Scala library Jar was found. Does root project '...' declare dependency to scala-library? Searched classpath: file collection.</i>

Apparently, replacing allprojects with subprojects seems to fix the problem.显然,用subprojects替换allprojects似乎可以解决问题。

Somehow, the project wanted to set the scala library for the root of the project, which contains no code.不知何故,该项目想为项目的根目录设置 scala 库,其中不包含任何代码。

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

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