Executing Lift Examples with SBT 0.11.3 and Eclipse

Recently we got our hands back on a Lift project after some time. A few of our clients had already moved from Lift to Play due to various reasons and one of them seemed to be dismal (read valid) documentation. There seem to be decent information like simply.liftweb.net and exploring.liftweb.net along with the book Lift in Action. But most of these resources seem to be still in the dark ages of getting built by sbt 0.7.5 and what not. I had a hard time getting a colleague of mine getting set up with the basic lift examples given that the other projects that we are currently executing are already on the latest versions. Anyway, here is a quick guide to get you out of the woods, faster.

Let us take an example, say you want to try the code from Snippets and Sitemap. You might want to clone the project from here https://github.com/dpp/simply_lift. You would find snippets and sitemap in the samples folder.

Now one option is to execute it with the sbt-launcher which comes along. Another is to get it converted to the relatively later version of sbt 0.11.3 (ok the latest on the block is 0.13) and use it from there

For that

0) First delete everything in the folder except the src folder

1) Introduce a build.sbt at the following root location which reads like this

name := "snippets"
organization := "my.company"
version := "0.1-SNAPSHOT"
scalaVersion := "2.9.1"
resolvers += "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"

resolvers += "Scala Tools Releases" at "http://scala-tools.org/repo-releases/"

resolvers += "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/"

seq(webSettings :_*)

libraryDependencies += "org.mortbay.jetty" % "jetty" % "6.1.22" % "container"

libraryDependencies ++= {
       val liftVersion = "2.4"
               "net.liftweb" %% "lift-webkit" % liftVersion % "compile",
               "net.liftweb" %% "lift-mapper" % liftVersion % "compile",
               "org.mortbay.jetty" % "jetty" % "6.1.26" % "test",
               "junit" % "junit" % "4.7" % "test",
               "ch.qos.logback" % "logback-classic" % "0.9.26",
               "org.scala-tools.testing" %% "specs" % "1.6.9" % "test"

2) To start a container add the following plugin.sbt under the project folder (if you do not have a project folder, just create one)
vikas@vikas-laptop:~/w/knoldus/fleisure/information/simply_lift/samples/snippet_and_sitemap/project$ ls
plugin.sbt project target
That should look like this

resolvers += Classpaths.typesafeResolver

resolvers += Resolver.url("Typesafe repository", new java.net.URL("http://typesafe.artifactoryonline.com/typesafe/ivy-releases/"))(Resolver.defaultIvyPatterns)

libraryDependencies <+= sbtVersion(v => v match {
case "0.11.0" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.0-0.2.8"
case "0.11.1" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.1-0.2.10"
case "0.11.2" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.2-0.2.11"
case "0.11.3" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.3-"

3) I am assuming you already have an eclipse plugin entry under your ~/.sbt/plugins/build.sbt
If not, add the following line

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

Now execute

$ sbt eclipse
to generate the eclipse files

$sbt ~container:start
to start the webapp with Jetty

On localhost:8080, you should see something similar to

About Vikas Hazrati

Vikas is the Founding Partner @ Knoldus which is a group of software industry veterans who have joined hands to add value to the art of software development. Knoldus does niche Reactive and Big Data product development on Scala, Spark and Functional Java. Knoldus has a strong focus on software craftsmanship which ensures high-quality software development. It partners with the best in the industry like Lightbend (Scala Ecosystem), Databricks (Spark Ecosystem), Confluent (Kafka) and Datastax (Cassandra). To know more, send a mail to hello@knoldus.com or visit www.knoldus.com
This entry was posted in Scala and tagged , , . Bookmark the permalink.

4 Responses to Executing Lift Examples with SBT 0.11.3 and Eclipse

  1. Hey Vikas ,
    I am getting below error while running git clone command :-

    Cloning into snippet_and_sitemap…
    fatal: https://github.com/dpp/simply_lift/tree/master/samples/snippet_and_sitemap/info/refs not found: did you run git update-server-info on the server?

    Please let me know if I am missing something .

  2. Thanks !..It worked for me ..

  3. For documentation, there’s also the start of a Cookbook at: http://cookbook.liftweb.net/

    Regarding more up-to-date SBT versions, the official SBT 0.11.3 Lift template is at https://github.com/lift/lift_25_sbt (discussed at https://groups.google.com/forum/#!topic/liftweb/6Xb219jQQz0%5B1-25%5D)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s