Gradle Scala 插件找不到 ScalaObject

Gradle Scala plugin cannot find ScalaObject

我在 GitHub 上有以下 Gradle-based Scala project

如果您克隆它并且 运行 ./gradlew run 您将得到以下异常:

:shared:compileJava UP-TO-DATE
:shared:compileScala
missing or invalid dependency detected while loading class file 'package.class'.
Could not access type ScalaObject in package scala,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'package.class' was compiled against an incompatible version of scala.
one error found
:shared:compileScala FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared:compileScala'.
> Compilation failed

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

我从 Google 众神那里找到的唯一可比较的堆栈跟踪都涉及 SBT 和 Scala 项目, Gradle 和斯卡拉

有人能知道这是怎么回事吗?

您似乎遇到了一些依赖冲突。我已经看到您在子项目中使用了不同的 Scala 版本。这可能会导致您的 Scala 版本和库之间存在一些二进制不兼容问题。

例如,您正在使用 'net.liftweb:lift-json_2.9.1:2.6.3',它与 Scala 2.9.1 二进制兼容,但您有 Scala 2.12.1Scala 2.11.8。这可能是潜在的候选问题。

如果我是你,我会检查所有依赖项列表并检查项目所需的正确版本。

您可以使用:
gradle dependencies
gradle dependencyInsight <dependency-name>

获取有关您的依赖项如何解析的更多信息。

希望对您有所帮助。