Using Maven and Eclipse to generate Scala Lift Web Applications

The Lift web framework is built on top of Scala which in turn runs on the Java Platform. Lift applications are built as WAR files and deployed to servlet containers such as Tomcat and Jetty.

The Maven archtetypes for Lift and the Scala IDE for Eclipse make it easy for a Java developer to start building and deploying Lift applications using familiar tools. Since Lift views (templates) are valid XHTML or HMTL5 the Eclipse IDE for Java EE Developers (Helios SR2) and its XML and HTML editors can be used to design Lift web interfaces.

Installing the Scala IDE and the M2Eclipse Maven plugin into the Eclipse IDE for Java EE Developers allows new Lift applications to be created by selecting a suitable Lift archtetype when creating a new Maven project.

For example the Maven command below uses the Lift basic archetype to generate a Lift project with a default H2 database, logging and user management.

mvn archetype:generate
-DarchetypeGroupId=net.liftweb -DarchetypeArtifactId=lift-archetype-basic_2.8.1
-DarchetypeVersion=2.2 -DarchetypeRepository= -DremoteRepositories=
-DgroupId=com._3kbo.scala -DartifactId=liftbasic -Dversion=1.0

The same Lift project can be generated from within Eclipse using the Maven new project wizard and selecting the Lift basic archetype (as shown below).

maven archetype

Apply the Scala nature to the project by first opening the project in the Scala perspective, select the project (e.g. liftbasic) in the package explorer and select  Configure | Add Scala Nature.

The application created using the Maven command line can be run in Jetty from the command line with the command:

mvn jetty:run

The web application can then be accessed at http://localhost:8080/.

Similarly the Eclipse Maven project can be run in Jetty within Eclipse by setting up and running a Runtime Configuration like the one below:

mvn jetty:run

Tags: , , , ,

2 Responses to “Using Maven and Eclipse to generate Scala Lift Web Applications”

  1. drozzy says:

    Great, post!

    Just to add, before you start the server – you may need to run “Maven install” in the project.

    But this is definitely should be in the core lift documentation. I don’t care for the SBT, so I don’t know why they keep insisting the I use it!

  2. [...] 3kbo Building Semantic Web Applications « Using Maven and Eclipse to generate Scala Lift Web Applications [...]