Dependencies

sbt has an in-depth documentation on the various dependency management solutions. This tutorial will cover only managed dependencies.

Adding dependencies

You add dependencies by specifying a groupId, _an _artifactId, a version _and an optional _configuration scope. In your build.sbt it looks like this

libraryDependencies += groupID % artifactID % revision

Example

Adding akka-actor looks like this

libraryDependencies += "com.typesafe.akka" % "akka-actor_2.12" % "2.5.6"

Scala dependencies append the scala version (in the example _2.12) to the artifactId. This is cumbersome and error prone when upgrading your scala version. This is why sbt provides a shortcut by using %% after the groupId. sbt will automatically add the scalaVersion defined in the project.

Example with automatic scalaVersion (recommended)

libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.5.6"

Dependency scopes

results matching ""

    No results matching ""