Create a LiftWeb project with Simple Build Tool

If you are like me an eternal beginner on the Lift Web Framework, after starting a few attempts you probably think that perhaps maven lift archetypes are sometimes really slow process to start a liftweb project, and also that you need something more intuitive as Rails or Grails. Most of the time, when I am using maven, I need to look on the documentation again and again. So I have decided that I would like to use other option such as the Simple Build Tool.

First, we are going to install sbt. I have already made a small tutorial of how to install sbt for Mac OS X Leopard users, which is located here

Once the SBT tool has finally been installed, we proceed to create the lift project structure, there are 2 ways to create a Lift Project, the first one to create a new project by the traditional means using maven:

  mvn archetype:generate \
           -DarchetypeGroupId=net.liftweb \
           -DarchetypeArtifactId=lift-archetype-basic_2.8.0 \
           -DarchetypeVersion=2.1                           \
           -DarchetypeRepository=http://scala-tools.org/repo-snapshots \
           -DremoteRepositories=http://scala-tools.org/repo-snapshots \
           -DgroupId=org.activoricordi.cloudconsole \
           -DartifactId=dbcloudconsole \
           -Dversion=1.0

Then use sbt to manage the rest. We later build the sbt project. However, this way of working is precisely what I want to avoid.

The other option is to use git and download the lift-sbt-prototype from the LiftWeb Prototype Site. If you have not downloaded git, I would suggest two options or either find at Google a good tutorial of how to do it or the other option is to wait for new tutorial where we explain how we install it in Eclipse.

We clone the project repository using the following command:

git clone git://github.com/lift/lift_sbt_prototype.git

But there is a better option, which is using Lifty. Lifty is a SBT processor for generating files associated with the Lift framework. It is a open source project created by Mads Hartmann, which is based on a sbt framework called Lifty engine, which we will describe another day.

Lifty site

Lifty site

mkdir lifty_test
cd lifty_test
sbt

Once we enter the sbt command the following message will appear:

Project does not exist, create new project? (y/N) : y

SBT Project Creation Line


If we select the option Y and we then to enter commands to fill the parameters appear:

  • Name:liftytest
  • Organization:org.lifty
  • Version [1.0]:1
  • Scala version [2.7.7]: 2.8.0
  • sbt version [0.7.4]: 0.7.4
  • Here we can see an screenshot of the process:

    sbt_project_creation_process

    Screenshot from sbt project creation process


    This means that we have created a normal scala project, where we have filled the necessary fields
    We then enter the following command at the sbt prompt which are located on this page: http://lifty.github.com/Lifty/:

    *lifty is org.lifty lifty 1.3
    

    This command download the lifty processor.

    To test it, we are going to enter the following command.

    lifty help
    

    The lifty processor is quite simple, supporting the following commands:

    help: This will list all of the available commands
    templates: This will list all of the available templates
    create: This will attempt to create on of the templates

    lifty create project
    

    This command creates all the structure needed to execute the project. Even it creates the command.

    import sbt._
     
    class LiftProject(info: ProjectInfo) extends DefaultWebProject(info) {
      val mavenLocal = "Local Maven Repository" at
      "file://"+Path.userHome+"/.m2/repository"
     
       val scalatoolsSnapshot = "Scala Tools Snapshot" at
      "http://scala-tools.org/repo-snapshots/"
     
      val scalatoolsRelease = "Scala Tools Snapshot" at
      "http://scala-tools.org/repo-releases/"
     
      val liftVersion = "2.1-SNAPSHOT"
     
      override def libraryDependencies = Set(
        "net.liftweb" %% "lift-webkit" % liftVersion % "compile->default",
        "net.liftweb" %% "lift-testkit" % liftVersion % "compile->default",
        "net.liftweb" %% "lift-wizard" % liftVersion % "compile->default",
        "net.liftweb" %% "lift-mapper" % liftVersion % "compile->default",
        "com.h2database" % "h2" % "1.2.138",
        "org.mortbay.jetty" % "jetty" % "6.1.22" % "test->default",
        "junit" % "junit" % "4.5" % "test->default",
        "org.scala-tools.testing" % "specs" % "1.6.1" % "test->default"
      ) ++ super.libraryDependencies
    }

    As a tip, I would recommend adding are going to add the following dependencies which I consider very valuable.

    "net.liftweb" %% "lift-widgets" % liftVersion % "compile->default",

    Once we add it we have to save the file and use the sbt reload command again.
    To summarize:
    a) We create the folder with the name of the project we want to create
    b) We access to the folder and we then use the sbt command
    c) Instead of filling it

3 thoughts on “Create a LiftWeb project with Simple Build Tool

  • Thanks, I’m a lift beginner and I was confused about maven and sbt when using lift. Your blog was very informative. But just to clarify, I would have to install sbt, then the lifty plugin for sbt, then use lifty to create the project.. right?Does that mean that one does not have to install maven or download the liftweb prototype when using sbt+lifty?

  • You could alternative use maven or sbt. Lifty is a sbt plugin which add a usability layer. Best thing about Maven is that is a more mature application and it is used for building Java projects. Sbt initially was more straight forward to use for building lift compared with Maven.

Comments are closed.