chengpohi chengpohi - 1 month ago 9
Scala Question

sbt 0.13.1 multi-project module not found when I change the sbt default scala library to scala 2.11.2

I use the sbt 0.13.1 create the two modules, and I create project/MyBuild.scala to compile this two modules.
MyBuild.scala:

import sbt._
import Keys._
object MyBuild extends Build {
lazy val task = project.in(file("task"))
lazy val root = project.in(file(".")) aggregate(task) dependsOn task
}


When I change the scala library to 2.11.2 by set scalaHome. It will go to maven download the task.jar and failed, that's very strange. Is it a sbt bug?

There is the github test project address: test-sbt-0.13.1

Answer

I'd recommend you to move the sources of root project from root to subfolder (task2), and add them as aggregated. It will remove aggregating and depending on same project:

object MyBuild extends Build {
          lazy val task = project.in(file("task"))
          lazy val task2 = project.in(file("task2")) dependsOn task
          lazy val root = project.in(file(".")) aggregate(task, task2) 
}

This works for me, but it's strange that such non-standard project structure works fine with default scalaHome. Seems to be a problem in the way in which sbt resolves such dependency as external.

P.S. This answer doesn't cover the whole story. See @jjst's answer to clarify more.

Comments