Lift quick start: Look Ma! No Maven

For the last year or so, I’ve been using the Lift web framework to develop our B2B SaaS application (my experiences can be found here). I’ve enjoyed this very much, especially the community, so when David Pollak asked me to be become a committer I couldn’t say no 🙂

One area where Lift is lacking is in documentation, so I’ll try to write a few posts here that can help people getting started using Lift. I’ll be writing about the workflow we use, since

  1. It works for us
  2. It is not using Maven, a source of some ….. frustration for many


There are many tutorials available that shows how to create a new Lift project, building and running using Maven. If you like maven and think that it’s fine, you should probably follow one of those, since this is the most common setup and you’re likely to find help on the mailing list. We’ve decided to use Gradle.

Why not SBT?

The Simple Build Tool is a cool build tool aimed primarily at Scala projects. It has nifty support for continuous compilation and testing. I haven’t used SBT, but hear it’s quite good (Lift may eventually move to SBT).

But I think many of the features that are cool about SBT (ie. the continuous compilation and testing) are most useful during development if you’re just using a text editor. If you’re using an IDE (such as Eclipse) it already handles this.

I mostly use a build tool for automating the build/test/deployment process and as such, I think Gradle is better suited since it is scripted in Groovy and has complete support for existing Ant tasks. But I really need to try out the Emacs+SBT combo at some point to see what all the fuzz is about 🙂


Ok, lets get started. To create and run your Lift projects, you need these packages installed and working:

  • A Java 1.5 (1.6 preferred) JRE installed
  • Git (not strictly necessary as you can download the files as zip/tar package from Github)

That’s it. No need for Maven, Gradle, Scala or anything else since we’re using a the nice Wrapper feature of Gradle that automatically downloads and installs the correct version of Gradle.

A minor note about versions

In these posts I’ll use the versions of various software that I know work. Both Scala, Lift and Gradle are about to release new versions which will improve many things, but I’m only using the Gradle pre-release. I’ll update the posts when the new Scala & Lift versions are more stable.

Creating a Lift project

Creating a project is as simple as cloning a project from Git:

$ git clone

This will fetch all the files from github. The project just created is a basic Lift application with database support (using H2) and simple user registration. The files follow a standard directory scheme.

The scala files are in src/main/scala and the web files (html, images etc) are in src/main/webapp. The file src/main/scala/bootstrap/liftweb/Boot.scala is where you customize most Lift settings, it is run once during startup. Check out the Lift documentation for more details.

Building and running the project

Gradle reads the build.gradle file to determine the tasks that are available in the project. The build.gradle in this project is fairly simple, mostly adding the repository and specifying the dependencies needed to compile and test the project.

// Minimal build.gradle for Lift project
apply {
    plugin 'scala'
    plugin 'war'
    plugin 'jetty'

scalaVersion = '2.7.7'
liftVersion = '2.0-M4'

jettyRun.contextPath = "/"

repositories {
    mavenRepo name:'scala-releases', urls:''

dependencies {
    scalaTools "org.scala-lang:scala-compiler:$scalaVersion",

    compile "org.scala-lang:scala-library:$scalaVersion",

    testCompile "junit:junit:4.5",

    providedCompile 'javax.servlet:servlet-api:2.5'

task wrapper(type: Wrapper) {
    gradleVersion = '0.9-preview-1'

In order to run a task you use the syntax

$ ./gradlew taskName

This will install gradle if it’s not already installed and then execute the specified task in the build script. So to compile the project and load it within the built-in Jetty web server, use the following command:

$ ./gradlew jettyRun

Running this (and ignore the warnings about multiple SLF4J bindings, this is a bug in the built-in jettyRun task) and  then browsing to http://localhost:8080 should show something like this:

To package the project such that it can be moved to a standalone web server, you can create a war file by executing

$ ./gradlew war

This will create the file build/libs/liftstart.war which can be copied to the apps directory of any servlet container.

Next steps

Ok, so you’ve created a Lift project and know how to run it using Gradle. So go crazy and start hacking!

But as you’ve probably noted, this is not exactly an efficient workflow since compiling everything from scratch takes quite a while. In a future post I’ll explain how to setup a fairly rapid development environment using Eclipse and JRebel.


2 responses to this post.

  1. Posted by Peter on June 16, 2010 at 01:22

    Great post.
    What about ‘future post’ which you mentioned? I have reached the point when compiling takes too much time, and I would love know how to setup JRebel.


    • Posted by Jeppe on June 16, 2010 at 08:39

      Thanks. As for the “future post” it’s still in the works 🙂 I’ve agreed with Miles (the author of the Eclipse plugin) not to post something on the Scala 2.7 plugin since it’s rather old now and basically unmaintained. Unfortunately, the 2.8 release have been delayed rather substantially and Lift didn’t work too well with some of the RCs. But it seems close now!


Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: