I'm trying to write a concise multi project Build.sbt, so I tried to put all library dependencies in root project and then make others depends on it. My Build.sbt looks like the following:
object KataBuild extends Build {
        lazy val fizzBuzz = Project(
            id = "fizzBuzz", 
            base = file("fizzBuzz"),
            settings = Project.defaultSettings ++ Seq(
                name := "fizzBuzz",
                version := "1.0",
                scalaVersion := "2.10.3"
            )
        )
        lazy val kata = Project(
            id = "scala-kata", 
            base = file("."),
            settings = Project.defaultSettings ++ Seq(
                name := "scala-kata",
                version := "1.0",
                scalaVersion := "2.10.3",
                libraryDependencies ++= Seq(
                    "org.scalatest" %% "scalatest" % "2.1.0" % "test"
                )
            )
        ) aggregate(fizzBuzz)
        fizzBuzz dependsOn(kata)
}
But running test from the main project (scala-kata) fails to build test for fizzBuzz. What am I missing?
Your question is similar to this one. In short, fizzBuzz.dependsOn(kata) means that its compile configuration depends on the kata's compile configuration, but you want to link the test configurations.
The 'Per-configuration classpath dependencies' section of the sbt docs show you how you can make a test->test dependency instead.
However, if you are not going to use kata's test sources but are just looking for a way to include Scala-Test in fizzBuzz, just add it explicitly to fizzBuzz's library dependencies, too. You can define a helper value
lazy val scalaTest = "org.scalatest" %% "scalatest" % "2.1.0" % "test"
Then you can add it to be sub project's library dependencies (libraryDependencies += scalaTest).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With