4

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?

0

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

Yes I don't need kata's test sources in subprojects. I just wanted the library dependency to be shared (declared just in kata project, with subProjects depending on it). So, as I understand this is not possible, I have to add it explicitly to all subProjects, or declare all the tests for subprojects inside kata/src/test. Am I right?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.