How to use SBTEclipse plugin with SBT 0.12.0

This blog post will explain you how to setup SBT with the SBTEclipse plugin for automatically creating Eclipse project files.

1) First, create a new directory in your Eclipse workspace with name of your own choice. In this post, I’ll use “SbtEclipseTest”.

2) You will need SBT: download the sbt-launch.jar from here. At the time of writing, supported versions are 0.11.3 and 0.12.0. Place the jar file inside your project directory and create a launch file (described here) by pasting this command inside an empty file (sbt.bat if Windows, sbt on linux/mac): java -Xmx512M -jar sbt-launch.jar

Note: if your network uses a proxy, then add the following arguments: -Dhttp.proxyHost=proxy.demo.com -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxy.demo.com -Dhttps.proxyPort=8080

3) Create a file called build.sbt with the following contents: (notice the line break between each line)

name := "SbtEclipseTest"

version := "1.0"

scalaVersion := "2.9.1"

libraryDependencies ++= Seq(
 "org.scalatra" %% "scalatra" % "2.0.4",
 "org.scalatra" %% "scalatra-test" % "2.0.4",
 "org.scalatra" %% "scalatra-scalatest" % "2.0.4",
 "org.eclipse.jetty" % "jetty-webapp" % "7.5.4.v20111024",
 "org.scalatest" %% "scalatest" % "1.8")

This configuration will give you an web-app using Jetty (app-server), Scalatra (web framework) and ScalaTest (test-framework). Also notice that it is only Scala version 2.9.1 that is supported at the time of writing (sept. 12).

4) Create a new directory called “project” inside your root-directory (/SbtEclipseTest/project) and then create a file called build.sbt in this folder as well:

resolvers += Classpaths.typesafeResolver

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0")

5) Go back to your root directory, SbtEclipseTest, then run SBT (enter ‘sbt’ at the command line), then write ‘eclipse’.

6) You should now a message saying “Successfully created Eclipse project files for project(s): SbtEclipseTest“.

7) Finally, simply import the newly created project into Eclipse.

More information about using SBTEclipse plugin here.

This entry was posted in Scala. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>