Ruby has the RubyGems package manager, which lets developers easily distribute and manage the installation of Ruby libraries; does Scala have anything like this?
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 firstname.lastname@example.org and email@example.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 are often noted at notes.implicit.ly, the archive is at notes.implicit.ly/archive, and you can search for tools at ls.implicit.ly.
- Asking questions on StackOverflow.com
The search engine at ls.implicit.ly is interesting. The owners advertise the site as “A card catalog for Scala libraries.” As they state on their website, they make two assumptions regarding their search process:
- The library you’re looking for is an open source library that’s hosted at GitHub.
- You build your projects with SBT.
For instance, if you search for “logging,” the website currently shows tools like the “Grizzled-SLF4J” library, but doesn’t show other logging projects that don’t meet their criteria.
- Chapter 18
The Scala Cookbook
This tutorial is sponsored by the Scala Cookbook, which I wrote for O’Reilly:
You can find the Scala Cookbook at these locations:
help support my writing
& keep this website running