0

I have a root build.sbt file that looks like this:

organization  := "com.acme.foo"

name          := "foo-parent"

version       := "1.0-SNAPSHOT"

scalaVersion  := "2.11.2"                                                                              

scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")

resolvers ++= Seq(
  "spray repo" at "http://repo.spray.io/"
)

lazy val root = project.dependsOn(rest,backend)
lazy val rest = project
lazy val backend = project.dependsOn(rest).settings(mainClass in (Compile, run) := Some("com.acme.foo.Main"), fork in run := true)

run in Compile <<= (run in Compile in backend)

In both the backend and rest modules the scalaVersion is also set to 2.11.2, however I keep getting this error when I try to compile from the root:

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.acme.foo#rest_2.10;1.0-SNAPSHOT: not found
[warn]  :: com.acme#foo_2.10;1.0-SNAPSHOT: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::

Why does it insist on looking for _2.10 versions of my modules?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
ThaDon
  • 7,826
  • 9
  • 52
  • 84
  • The file you posted works for me (sbt 0.13.0). It compiles without any errors. The root, rest and backend projects have the default scala version though (defined by sbt version, 2.10.2 in my case). – Darko Cerdic Aug 18 '14 at 12:49
  • Run `sbt scalaVersion` in the top-level directory/project and see what value it holds for each project. It could also be that one of the dependencies declare Scala cross-version explicitly. – Jacek Laskowski Aug 18 '14 at 21:43

1 Answers1

2

I couldn't tell you why this worked, but I followed this answer, and it solved my problem

Someone had asked me in the comments what the result of executing sbt scalaVersion was. Originally it was:

[info] backend/*:scalaVersion
[info]  2.11.2
[info] rest/*:scalaVersion
[info]  2.11.2
[info] root/*:scalaVersion
[info]  2.10.3
[info] foo/*:scalaVersion
[info]  2.11.2

After taking the advice from the other SO post by replacing scalaVersion := "2.11.2" in my root's build.sbt file with:

scalaVersion in ThisBuild := "2.11.2"

I then got the correct result from sbt scalaVersion, and my compile worked fine:

[info] backend/*:scalaVersion
[info]  2.11.2
[info] rest/*:scalaVersion
[info]  2.11.2
[info] root/*:scalaVersion
[info]  2.11.2
[info] foo/*:scalaVersion
[info]  2.11.2

SBT just baffles me sometimes... but I must confess I haven't invested a lot of time in understanding it.

Community
  • 1
  • 1
ThaDon
  • 7,826
  • 9
  • 52
  • 84