libraryDependency
is the SettingKey
that handles 'managed' library dependencies, which are dependencies that are automatically downloaded, matching the supplied versions. To add a single dependency:
libraryDependencies += "com.typesafe.slick" %% "slick" % "3.2.0-M1"
The first part, "com.typesafe.slick"
, indicates the library package. The second part, "slick"
, is the library in question. The final part, "3.2.0-M1"
, is the version. Because the library is joined by %%
the version of Scala supplied by the scalaVersion
setting key will be utilized.
You can add multiple libraries at once using ++=
:
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "3.2.0-M1" % "compile",
"com.typesafe.slick" %% "slick-hikaricp" % "3.2.0-M1",
"mysql" % "mysql-connector-java" % "latest.release"
)
Remember Scala's functional nature, allowing you to compute dependencies. Just remember to return a Seq
:
libraryDependencies ++= {
lazy val liftVersion = "3.0-RC3" //Version of a library being used
lazy val liftEdition = liftVersion.substring(0,3) //Compute a value
Seq(
"net.liftweb" %% "lift-webkit" % liftVersion % "compile", // Use var in Seq
"net.liftmodules" %% ("ng_" + liftEdition) % "0.9.2" % "compile", // Use computed var in Seq
) // Because this is the last statement, the Seq is returned and appended to libraryDependencies
}