Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 464
jbrown Avatar asked Oct 18 '22 23:10

jbrown


1 Answers

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).

like image 156
Alexey Romanov Avatar answered Nov 15 '22 07:11

Alexey Romanov