Managing dependencies in sbt

I was just wondering how are you dealing with a problem of library dependencies in Scala projects. Let’s say I want to add Akka Streams dependecy. What I am doing right now is to define a variable and use it whenever I have to

val akkaStreamV = "2.5.19"

libraryDependencies += "com.typesafe.akka" %% "akka-stream" % akkaStreamV
libraryDependencies += "com.typesafe.akka" %% "akka-stream-testkit" % akkaStreamV % Test

I don’t know if there is some smarter way of doing it / organizing dependencies. Right now, I am repeating the same code through each submodule that needs this dependency and I don’t find it appealing.


What I do for larger multi-module projects is putting the dependencies in a separate file and include that. For sbt, you can put Scala files in the project directory and they will be available from your build.sbt files (as long as they actually are submodules of the build.sbt with that project directory, otherwise you’ll still have to copy the files to the respective project/ dir). For example:


import sbt._

object Dependencies {

  val scalatags = "com.lihaoyi" %% "scalatags" % "0.6.5"

  // can also group several dependencies in a Seq, if always used together
  val cats = Seq(
    "org.typelevel" %% "cats-core" % "1.0.1",
    "org.typelevel" %% "cats-effect" % "1.0.0-RC2",



libraryDependencies += Dependencies.scalatags // single
libraryDependencies ++= Dependencies.cats     // seq