Dave Perrett

'Hello World' With Scala and Lift on OSX

database, java, lift, osx, programming, scala, web

Obviously we’re going to need scala before we can do anything useful; the easiest way to install it is via macports . We’re also going to need maven.

1
2
> sudo port install scala
> sudo port install maven2

Scala seems to have moved their repository to github, and the old google code repository no longer works. Assuming you have git installed (if not, there’s an OS X installer here) :

1
2
3
4
5
> mkdir -p Documents/code/scala
> cd Documents/code/scala
> git clone git://github.com/dpp/liftweb.git
> cd liftweb
>  mvn clean:clean install

The mvn install may take quite a while.

At this point i got an error :

1
 Required goal not found: org.apache.maven.plugins:maven-archetype-plugin:jar in org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-7

… which i think might have been because Little Snitch blocked a request or something… I ran mvn clean:clean install again and after a few complaints from Little Snitch, success :

1
2
3
4
5
6
7
8
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 minutes 50 seconds
[INFO] Finished at: Tue Aug 18 03:47:19 JST 2009
[INFO] Final Memory: 50M/63M
[INFO] ------------------------------------------------------------------------
mvn clean:clean install  360.40s user 51.08s system 87% cpu 7:50.98 total

Next, it’s time to create our new project :

1
2
3
4
5
6
7
> cd ..
> mvn archetype:create -U  \
 -DarchetypeGroupId=net.liftweb                             \
 -DarchetypeArtifactId=lift-archetype-basic                 \
 -DarchetypeVersion=1.0                            \
 -DremoteRepositories=http://scala-tools.org/repo-releases  \
 -DgroupId=net.liftweb.hello -DartifactId=hello-lift

This should create a hello-lift folder with your new application in it. There are several archetypes available- this example uses lift-archetype-basic, which provides basic database support and a basic stylesheet. To run it :

1
2
> cd hello-lift/
> mvn install jetty:run

… and point your browser at http://localhost:8080/ , and you should be in business!