Should I include scala-compiler as a dependency in build.sbt?

大城市里の小女人 提交于 2020-02-03 07:48:09

问题


I'm trying to build a project with scala 2.11.7 in intellij. I've set the scalaVersion to 2.11.7, but when I check the external libraries, I can see scala-compiler:2.11.0.

Do I need to declare scala-compiler:2.11.7 as a dependency in build.sbt? The docs are confusing, seemingly saying that I do need to and then not to in consecutive paragraphs:

When using a Scala dependency other than the standard library, add it as a normal managed dependency. For example, to depend on the Scala compiler,

libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value

and

In order to compile Scala code, run scaladoc, and provide a Scala REPL, sbt needs the scala-compiler jar. This should not be a normal dependency of the project, so sbt adds a dependency on scala-compiler in the special, private scala-tool configuration.

So... should I add it or not?


回答1:


If your project's code uses scala-compiler (e.g. to parse or compile Scala code, to run a REPL, etc.), add it. Otherwise, don't. That's why the first quote says "When using a Scala dependency other than the standard library..."

scala-compiler shown in External Libraries is probably there because one of your other dependencies depends on it (and that version was compiled with Scala 2.11.0).



来源:https://stackoverflow.com/questions/33414163/should-i-include-scala-compiler-as-a-dependency-in-build-sbt

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