The Simple Build Tool (SBT for short) can be used to build Scala (or Java) project code. This includes managing code, dependencies, and resources that must be built, tested, and/or compiled to a
.jar or other artifact. Custom tasks can be created to manage all of these processes.
A note on the name; SBT is sometimes referred to as the ‘Scala Build Tool’. While this was not the original intent, it has come to be commonly used as well. SBT may be used to build any project on the JVM.
.sbt files, or ‘SBT build definitions’ are specially interpreted files, written in Scala, that are used by SBT to define a build.
.scala build definitions may also be written and imported into an
Versions prior to
13.6 required that any
.sbt file has each statement separated by a blank line. Without the blank line, the
.sbt file will break.
Install SBT on Linux
Full instructions can be found here.
Set the Java Environment variable.
export JAVA_HOME=/usr/local/java/jdk1.8.0_102 echo $JAVA_HOME /usr/local/java/jdk1.8.0_102 export PATH=$PATH:$JAVA_HOME/bin/ echo $PATH ...:/usr/local/java/jdk1.8.0_102/bin/
sudo wget https://www.scala-lang.org/files/archive/scala-2.11.8.deb sudo dpkg -i scala-2.11.8.deb sudo apt-get update sudo apt-get install scala
wget https://bintray.com/artifact/download/sbt/debian/sbt-0.13.9.deb sudo dpkg -i sbt-0.13.9.deb sudo apt-get update sudo apt-get install sbt
RPM-based Linux Distributions
Download SBT repository definitions and add it to YUM:
curl https://bintray.com/sbt/rpm/rpm | sudo tee /etc/yum.repos.d/bintray-sbt-rpm.repo
Install SBT according to the definitions previously added to YUM:
sudo yum install sbt
Install SBT on Windows
WindowsKey + R, type
Alternatively, navigate to the
.sbt(for example, in
C:\Users\Hopper) and type
cmdin the address bar.
sbt aboutto get version information, verifying it is installed. You should see something like this:
Java HotSpot(TM) 64-But Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 [info] Set current project to root--sbt (in build file:/C:/Users/Hopper/.sbt/) [info] This is sbt 0.13.8 ...
Install on Mac OSX
Full official instructions can be found here.
Install MacPorts. Then, in the terminal execute:
port install sbt
Install Homebrew. Then, in the terminal execute:
brew install sbt
Download sbt All platforms (tgz) installation from SBT.
sudo su cd /opt mkdir sbt cd sbt curl https://dl.bintray.com/sbt/native-packages/sbt/0.13.13/sbt-0.13.13.tgz -o sbt-0.13.13.tgz
Then, execute following
tar zxf sbt-0.13.13.tgz ln -s sbt-0.13.13 latest
Inside your $HOME make sure to update ~/.profile - by adding following lines
export SBT_HOME=/opt/sbt/latest export PATH=$PATH:$SBT_HOME/bin
In the terminal execute:
You should expect output similar to:
If you get no output sbt is not installed.
Import SBT Project into Eclipse
Install the SBT plugin for Eclipse from the Eclipse marketplace.
In the command line switch directory to the root directory of the project.
$ cd ~/home/sample/project
Execute sbt, which will load the project.
Compile the project to ensure dependencies are obtainable.
Go into Eclipse and select the menu option:
File > New > Project From Existing Sources
In the wizard, navigate to your project directory and select it. Eclipse will handle the rest.