Friday, August 14, 2009

Getting Scala and Lift 1.1 working without Maven

I want to tinker with Scala and Lift without Maven. It was a bit of a headache to get started, so I'm going to detail what I did, and maybe the information will help someone else.

First, my employer uses a very different application folder layout than the Maven default - and I find it far more intuitive to use. Here are the folders in my project directory:
docs/ (documentation)
src/ (source code root folder)
src/bootstrap/liftweb/ (Boot.scala Lift starting point)
src/com/mycompany/scala/liftweb/myliftapp/ (root of Scala code for my Lift app)
src/com/mycompany/scala/liftweb/myliftapp/snippets (location of Scala code for my Lift "snippets")
src/test/com/mycompany/scala/liftweb/myliftapp/ (location of test Scala code for my Lift app)
webapps/myliftapp/ (root of the web application)
webapps/myliftapp/templates-hidden/ (hidden templates for Lift)
webapps/myliftapp/WEB-INF/classes (compiled Java and Scala classes folder)
webapps/myliftapp/WEB-INF/lib (library location)

Then, to package my .war file I just zip the contents of the project root /webapps/myliftapp/ directory. To me this folder layout seems more intuitive than the Maven default. As a bonus, on my local workstation I set up Apache Tomcat Java web server to use project root /webapps/myliftapp/ is a Context Base, so I restart Tomcat (or reload that application) to get relatively quick development feedback while building the application.

To make it work, I needed a JDK 1.5+, Scala 2.7.5, and downloading the following .jar files and putting them into the lib directory:
commons-collections-3.2.1.jar (Apache Commons Collections)
commons-fileupload-1.2.1.jar (Apache Commons File Upload)
log4j-1.2.15.jar (Log4j)
scala-library.jar (Included in Scala 2.7.5)
And the following can be found under http://scala-tools.org/repo-releases/net/liftweb/
lift-actor-1.1.jar
lift-util-1.1.jar
lift-webkit-1.1.jar

I got up and running in under two hours.

Thursday, August 13, 2009

Scala, Lift, and (yuck!) Maven

I've developed an intense interest in Scala (http://www.scala-lang.org) and Lift (http://liftweb.net/), but the Lift main website only has instructions to set up Lift with Maven (http://maven.apache.org/). As of today Maven is broken on Debian Squeeze/Sid (package dependency on libmaven-scm-java is broken).

Jim McBeath is my hero, he compiled instructions to set up Lift without Maven:
http://jim-mcbeath.blogspot.com/2009/05/lift-without-maven.html


This fellow (which Jim links to) has a list of reasons and a good discussion about disliking Maven.
http://ghostganz.com/blog/articles/2008/10/26/the-things-that-are-wrong-with-maven

My reasons are simple:
1. I am trying to understand Scala and Lift. I don't need to add Maven to the list.
2. I want to understand the architecture of a complete, packaged Lift application .war archive. Maven hides a lot of those details from me and has its own non-trivial learning curve, and that is tremendously annoying.