Gradle Scala插件找不到ScalaObject

时间:2017-03-14 00:37:45

标签: scala gradle gradle-plugin

我在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 Gods中找到的唯一可比较的堆栈跟踪包括SBT和Scala项目,不是 Gradle和Scala。

有人可以弄清楚这里发生了什么吗?

1 个答案:

答案 0 :(得分:3)

看起来你有一些依赖冲突。我已经看到你在子项目中使用不同的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>

获取有关依赖关系如何解决的更多信息。

我希望这有用。