Creating Scala Project With SBT 0.12

I have recently started working with scala. SBT is the tool of choice for Scala based projects. Let us see how to get it working on windows.

Installing SBT for Windows
Create a batch file sbt.bat which contains following script

Now, put the sbt-launch.jar file in same directory where you put sbt.bat file.Put sbt.bat on your path so that you can launch sbt in any directory by typing sbt at the command prompt.
After installing SBT if we type in sbt in the command prompt in an empty directory, this is what we are likely to see

In order to create project execute the following commands in the sbt session.

SBT creates files and directories when we executed the commands. It creates build.sbt and it contains the same values we typed in sbt session. Other directories like target and project are of little consequence to us.
My project directory contains following sub directories
This is how my my build.sbt files looks like after executing the commands in sbt session

One thing that has also changed from the past is that the src directories are not created by default. I used the sbteclipse plugin to do it for me.
Create file plugins.sbt inside project and add the following contents :

Execute the following command.

After execute eclipse command, following directory created as following

It creates common source directories like src/main/scala, src/main/test, etc and also eclipse project files.

The project is ready to imported in Eclipse IDE.That is all we need for creating Scala project using the latest SBT. We now know how to create an Scala project using SBT.

4 thoughts on “Creating Scala Project With SBT 0.12

  1. Is there a way to pass version :=”1.0″ along with command line? We use the command sbt one-jar to build our project, which will create a jar file, which will have name projectname_1.0_scalaversion.jar , If i can pass version in the command line itself, I can calculate the number of commits to my git repo and set that as a version: argument, that way I can name my jar better.

Leave a Reply

%d bloggers like this: