Reputation: 6508
I have a warning which lead to execution error :
[info] Set current project to calculator (in build file:/home/guillaume/projects/scala/2/)
[info] Updating {file:/home/guillaume/projects/scala/2/}root...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[warn] Scala version was updated by one of library dependencies:
[warn] * org.scala-lang:scala-library:2.10.5 -> 2.11.1
[warn] To force scalaVersion, add the following:
[warn] ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }
[warn] Run 'evicted' to see detailed eviction warnings
[info] Compiling 3 Scala sources to /home/guillaume/projects/scala/2/target/scala-2.10/classes...
[success] Total time: 9 s, completed Apr 5, 2016 12:16:04 AM
This is strange because my scala version is > 2.11 :
$ scala -version
Scala code runner version 2.11.8 -- Copyright 2002-2016, LAMP/EPFL
$sbt sbtVesion
[info] 0.13.9
My build.sbt :
lazy val root = (project in file(".")).
settings(
name := "calculator",
libraryDependencies += "jline" % "jline" % "2.12",
libraryDependencies += "com.typesafe.akka" % "akka-actor_2.11" % "2.3.4"
)
I just don't understand why my scala library is outdated.
Upvotes: 5
Views: 464
Reputation: 139038
The Scala version used by your SBT build is determined by your SBT configuration, not your system Scala version. The default Scala version for SBT 0.13 is 2.10, but you can change it with the following setting in your build.sbt
:
scalaVersion := "2.11.8"
The fact that your SBT project's Scala version doesn't depend on your system Scala version (if there even is one) is actually pretty handy—it means you can have projects that cross-build for multiple Scala versions, that you can build projects on machines that don't have Scala installed, etc.
One other note—it's a good idea to avoid this kind of mismatch by using the %%
syntax for Scala dependencies—e.g. this:
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.4"
Instead of this:
libraryDependencies += "com.typesafe.akka" % "akka-actor_2.11" % "2.3.4"
The %%
before the artifact name says "use this name but suffix it with _<Scala epoch version>.<Scala major version>
for whatever the currently configured Scala version is".
Upvotes: 14