Trying to cross compile a project to Scala 2.11 fails with “error while loading Object, Missing dependency 'object scala in compiler mirror'”

ⅰ亾dé卋堺 提交于 2019-11-28 11:57:44

The problem is very simple, in your Build.scala, you did almost all right, but in commons project you had overridden default commonDependencies. By default it contains dependency to scala-library.

This piece of code

lazy val common = Project(
    id = commonName,
    base = file(commonName),
    settings = Configuration.baseSettings ++ Seq(
      name := commonName,
      libraryDependencies := Configuration.commonDependencies // #1
    )
  )

at the element marked as #1 should have

libraryDependencies ++= Configuration.commonDependencies

Ps. I've sent you a pull request with the fix.

I was getting this error when trying to use the Oracle Java 9 jvm on Ubuntu with sbt. Using the Java 8 jvm worked for me, though.

Andrzej Jozwik

I think you answered before your questions Multimodule project build with SBT breaks with weird error

In this build add a line "org.scala-lang" % "scala-library" % projectScalaVersion,:

 val commonDependencies = Seq(
    ..
    "org.joda" % "joda-convert" % "1.5",
    "org.scala-lang" % "scala-library" % projectScalaVersion,
    "io.netty" % "netty-all" % "4.0.18.Final",
    ...
  )

In Build.scala I would add autoScalaLibrary := true:

lazy val common = Project(
    id = commonName,
    base = file(commonName),
    settings = Configuration.baseSettings ++ Seq(
      ...
      autoScalaLibrary := true,
      ...
    )
  )

This problem was solved for me when using intellij, by closing the project and reimporting it, and selecting sbt as the build system in settings.

Why oh why did I choose SBT?? Now I'm stuck with a very brittle build system. Thank God that atleast intellij does it right.

sbt version: 0.13.15

scala version: 2.12.1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!