A build.sbt example

build.sbt is the main file Sbt uses to understand how a project is organized and how to build it. There are several topics you are expected to address in this files. Lets see an example:

name := "hivedump"

version := "0.2"

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
    "org.apache.hive" % "hive-common" % "1.2.0",
    "org.apache.hive" % "hive-metastore" % "1.2.0",
    "org.apache.hive" % "hive-cli" % "1.2.0"
)

resolvers += "conjars" at "http://conjars.org/repo"

resolvers += "clojars" at "https://clojars.org/repo"

The name line states the name of the project. Easy enough to guess, you’re right. The version line states the version of the project. OK, know things are getting more interesting. The scalaVersion states the version of the Scala language this project is developed on.

One of the major problems in software building is dependency resolution. Downloading and placing jars (or shared libraries, or modules, or …) is boring and error prone. With the libraryDepencies entry of build.sbt you can state the complete list of direct dependencies of your project. The three pieces that form each line maps to the GroupId, ArtifactId and Version fields of a standard Maven dependency. If a dependency if not available in Maven central, but another repo provides it, a resolvers line can be added to provide its URL, as done for conjars and clojars in the previous example.

It mandatory to put a blank line between each configuration line.