Setup

Setup

Overview

To create an sbt project, you'll need to take these steps:

  • Install sbt and create a script to launch it.
  • Setup a simple hello world project
    • Create a project directory with source files in it.
    • Create your build definition.
  • Move on to running to learn how to run sbt.
  • Then move on to .sbt build definition to learn more about build definitions.

Installing sbt

sbt comes pre-built with several available packages for different operating systems.

Here's the available download packages:

Please report any issues to the sbt-launcher-package project.

You may also try out the Manual Installation.

Gentoo

In official tree there is no ebuild for sbt. But there are ebuilds to merge sbt from binaries: https://github.com/whiter4bbit/overlays/tree/master/dev-java/sbt-bin. To merge sbt from this ebuilds you can do next:

$ mkdir -p /usr/local/portage && cd /usr/local/portage
$ git clone git://github.com/whiter4bbit/overlays.git
$ echo "PORTDIR_OVERLAY=$PORTDIR_OVERLAY /usr/local/portage/overlays" >> /etc/make.conf
$ emerge sbt-bin

Note

Please report any issues with the ebuild here.

Mac

Use either MacPorts:

$ port install sbt

Or HomeBrew:

$ brew install sbt

Note

Please make sure to report any issues with these packages to the relevant maintainers.

Manual Installation

Windows

Create a batch file sbt.bat:

$ set SCRIPT_DIR=%~dp0
$ java -Xmx512M -jar "%SCRIPT_DIR%sbt-launch.jar" %*

and put sbt-launch.jar in the same directory as the batch file. Put sbt.bat on your path so that you can launch sbt in any directory by typing sbt at the command prompt.

Unix

Download sbt-launch.jar and place it in ~/bin.

Create a script to run the jar, by placing this in a file called sbt in your ~/bin directory:

java -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M -jar `dirname $0`/sbt-launch.jar "$@"

Make the script executable:

$ chmod u+x ~/bin/sbt

Tips and Notes

If you have any trouble running sbt, see Setup Notes on terminal encodings, HTTP proxies, and JVM options.

To install sbt, you could also use this fairly elaborated shell script: https://github.com/paulp/sbt-extras (see sbt file in the root dir). It has the same purpose as the simple shell script above but it will install sbt if necessary. It knows all recent versions of sbt and it also comes with a lot of useful command line options.