14.7. Finding Scala Libraries
Problem
Ruby has the RubyGems package manager, which lets developers easily distribute and manage the installation of Ruby libraries; does Scala have anything like this?
Solution
Prior to Scala 2.9.2, a tool named sbaz
shipped
with Scala, but it wasn’t very popular. Instead, most tools are
“discovered” by paying attention to the mailing lists, using a search
engine, and being aware of a few key websites.
As discussed in Chapter 18, once you’ve found a tool you want to use, you usually add it as a dependency to your project with SBT. For instance, to include libraries into your project, such as ScalaTest and Mockito, just add lines like this to your SBT build.sbt file:
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/" libraryDependencies ++= Seq( "org.scalatest" %% "scalatest" % "1.8" % "test", "org.mockito" % "mockito-core" % "1.9.0" % "test" )
SBT has become the de facto tool for building Scala applications and managing dependencies. Possibly because of this success, a system like RubyGems hasn’t evolved, or been necessary.
Some of the top ways of finding Scala libraries are:
Searching for libraries using a search engine, or ls.implicit.ly.
Asking questions and searching the scala-tools@googlegroups.com and scala-language@googlegroups.com mailing lists.
New software is also announced at the “scala-announce” mailing list; you can find a list of Scala mailing lists online.
Viewing tools listed at the Scala wiki.
Scala project updates ...
Get Scala Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.