How to inherit unmanaged dependencies in submodules in sbt?
sbt
Solution
This is a correct `build.sbt`:
lazy val a, b = project settings(
Defaults.defaultSettings ++ Seq(
unmanagedBase := (unmanagedBase in ThisProject).value
): _*
)
The idea is to set `unmanagedBase` for the submodules based upon the value of the setting in the root project (that's defined implicitly).
In your particular case it'd be as follows:
import sbt._
import Keys._
object RootBuild extends Build {
lazy val buildSettings = Defaults.defaultSettings ++ Seq(
scalaVersion := "2.11.1"
)
lazy val standardSettings = buildSettings ++ Seq(
libraryDependencies ++= Seq(
"org.scalatest" % "scalatest_2.11" % "2.1.6" % "test",
"org.testng" % "testng" % "6.8.8"
)
)
lazy val submoduleSettings = standardSettings ++ Seq(
unmanagedBase := (unmanagedBase in ThisProject).value
)
lazy val root = project in file(".") settings(standardSettings: _*) aggregate(core, clp)
lazy val core = project settings(submoduleSettings: _*)
lazy val clp = project settings(submoduleSettings: _*) dependsOn core
lazy val server = project settings(submoduleSettings: _*) dependsOn core
}
Problem
I have a project which looks like this, using sbt 0.13.2: ``` base - project - Build.scala - plugins.sbt - lib - unmanaged jar #1 - unmanaged jar #2 - core - src - ....... - clp - src - ....... - server - src - ...... ``` where `core` contains common code and `clp` and `server` are two related projects which both depend on `core`. I'm trying to find the right mojo in `Build.scala` such that all three of these modules depend on `base/lib`. Currently I'm cheating by using a symlink'd `lib` dir in each of the modules, but I'd like to do it automatically without the symlinks. Here's an example of `Build.scala` file - how should I modify this to make the dependencies work? ``` import sbt._ import Keys._ object RootBuild extends Build { lazy val buildSettings = Defaults.defaultSettings ++ Seq( scalaVersion := "2.11.1", unmanagedBase := baseDirectory.value / "lib" ) lazy val standardSettings = buildSettings ++ Seq( libraryDependencies ++= Seq( "org.scalatest" % "scalatest_2.11" % "2.1.6" % "test", "org.testng" % "testng" % "6.8.8" ) ) lazy val Projects = Seq(root, core, clp) lazy val root = Project("root", file("."), settings=standardSettings) aggregate(core, clp) lazy val core = Project("core", file("core"), settings=standardSettings) lazy val clp = Project("clp", file("clp"), settings=standardSettings) dependsOn core lazy val server = Project("server", file("server"), settings=standardSettings) depensOn core } ```