IntelliJ, SBT, and Lift


Update: This is easier now. See this post: http://www.morroni.com/blog/2011/03/11/the-best-lift-sbt-intellij-startup-process/
This post describes how to get IntelliJ, Git, SBT(Scala Build Tool) and Lift playing nicely together. This post assumes you have Maven and SBT already installed since you will need them in order to make this work. More information about the sbt setup is here: http://code.google.com/p/simple-build-tool/wiki/Setup. Information about installing maven is available here: http://maven.apache.org/run-maven/index.html

Install GIT

  1. Browse to http://code.google.com/p/git-osx-installer/
  2. Install the git package.
  3. After installation, you need to run a shell command to finish things properly. it sets paths and what not.
  4. Open up a terminal.
  5. Change directories to the mounted image
  6. bash$ cd /Volumes/Git 1.6.4.4 Intel Leopard/
  7. bash$ ./setup git PATH for non-terminal programs.sh
  8. Close your terminal and reopen it. Now type git and confirm it is installed.

Download archetype

  1. Open up terminal and browse to a folder where you will store your project.
  2. Type the following:
  3. mvn archetype:generate -U
    -DarchetypeGroupId=net.liftweb
    -DarchetypeArtifactId=lift-archetype-basic
    -DarchetypeVersion=2.0
    -DremoteRepositories=http://scala-tools.org/repo-releases
    -Dversion=0.1
    -DgroupId=com.myCompany.myProject -DartifactId=myProject
  4. Change into the folder where the project was created and type <code>sbt update</code>.  this will download the libraries and crate the sbt project folder.

Open IntelliJ

I did a pretty verbose post on using IntelliJ with lift here:  http://www.morroni.com/blog/2010/07/14/setup-intellij-9-for-lift-framework-development/. This assumes you have installed the Scala and SBT plugins in IntelliJ.

  1. Now we open up IntelliJ and import the maven project.  File -> New Project ->Import Project From External Model.
  2. Let IntelliJ do its thing and when it is done, we will need to add a class describing sbt build information.  Create a folder inside project/build and create a file called LiftProject.scala.  Place the following inside that file.
    import sbt._
    class LiftProject(info: ProjectInfo) extends DefaultWebProject(info) {
    val liftVersion = "2.0"

    override def libraryDependencies = Set(
    "net.liftweb" % "lift-webkit" % liftVersion % "compile->default",
    "net.liftweb" % "lift-mapper" % liftVersion % "compile->default",
    "org.mortbay.jetty" % "jetty" % "6.1.22" % "test->default",
    "junit" % "junit" % "4.5" % "test->default",
    "org.scala-tools.testing" % "specs" % "1.6.2.1" % "test->default",
    "com.h2database" % "h2" % "1.2.138"
    ) ++ super.libraryDependencies
    }

  3. Open up a terminal and inside your project folder type sbt ~jetty-run
  4. Open up your web browser and browse to http://staging.morroni.com:8080
  5. Hopefully, you see your project.  if not, it’s probably because my post was too terse.  I apologize, but a lot of these posts are just so I do not forget certain processes :)