Reputation: 831
I have a multi-module SBT project where several of the subprojects depend on the same artifacts. I would like to manage the versions of these common dependencies at the root project so that I can do something like this in the subprojects (global.SprayVersion
should come from the root project):
libraryDependencies += "io.spray" % "spray-client" % global.SprayVersion
What I've tried:
val
for each dependencyval myDepVersion = '1.0'
Should I define new SettingKeys for each dependency? This seems a bit overkill to me. I would like to keep a bit more grouped, not polluting the setting key namespace. Also, the subprojects don't need to be able to override these values.
Upvotes: 1
Views: 1034
Reputation: 127751
You can define a sequence of dependencies, for example, in a separate object, like this:
object Deps {
val akka = Seq(
"com.typesafe.akka" %% "akka-actor" % Global.akkaVersion,
"com.typesafe.akka" %% "akka-slf4j" % Global.akkaVersion
"com.typesafe.akka" %% "akka-testkit" % Global.akkaVersion % "test"
)
}
where Global
is just an object with a number of strings in it:
object Global {
val akkaVersion = "2.2.4"
}
Then you can just use Deps
contents in your subprojects:
val project1 = Project(...)
.settings(libraryDependencies ++= Deps.akka)
val project2 = Project(...)
.settings(libraryDependencies ++= Deps.akka)
Upvotes: 3