Version 11, last updated by deteego at 19 Jan 19:18 UTC

Using IntelliJ IDEA to develop Lift applications

For all of the methods outlined below you will need the Scala plugin for Intellij (additional plugins for methods are specified in the requirements).

Using Maven combined with SBT

Requirements and Notes

For this method you will need the SBT and Maven plugin (the maven plugin should be installed by default). IntelliJ will manage your dependencies using the POM, you will build and run with SBT.

Note that when using this method, IntelliJ will just work as a code completion/syntax checking/import managing tool, you will have to build the program using SBT

Steps

  1. Use one of the Maven archetypes referenced elsewhere on this wiki to create a Lift project. The pom.xml will be used by IntelliJ to import your dependencies
  2. Create an SBT project on top of the Maven project (enter the project directory and run SBT)
  3. Create a new IntelliJ project from what results, using Import Project from External Model => Maven
  4. Add a Scala aspect to the project, employing Use Files. Point the plug-in to the project/boot subdirectory where SBT downloaded your Scala
  5. Develop with pleasure :)

Using Pure Maven

Requirements and Notes

Apart from the Scala plugin which you should have already installed you will not need to install any extra plugins (Maven plugin should be installed by default). Since IntelliJ has full Maven integration, using this method you can both develop and build purely within Intellij.

Steps

  • Create a new project in Intellij, using Create a project from scratch
  • Under Select Type select Maven Module. Fill out the other fields as desired. Then click next
  • Fill in the GroupId and ArtifactId as desired (typically the GroupId is your 'company' and ArtifactId is the 'name' of your project). Select Create from archetype and click on Add archetype...
  • In this section you specify what kind of lift project you want to start off with. Set the GroupId to net.liftweb and Repository to http://scala-tools.org/repo-releases. If you want the basic project for Lift 2.3 using Scala 2.8.1, set the ArtifactId to lift-archetype-basic_2.8.1 and Version  to 2.3 (for more info on other versions see http://www.assembla.com/spaces/liftweb/wiki/Using_Maven). Click on finish when you are done
  • The project will now be built by IntelliJ, when its finished you will see a lot of dialog popups and other notifications as IntelliJ detects various aspects of your lift project. You will get a notification about a Web Facet being detected, click on Create Web Facet (this is a plugin for syntax highlighting and various other features for xml,html,js and other types of web files in your lift project). You will also see a notification that Maven projects need to be imported, either click Import Changes (or Enable Auto-Import if you don't want to do this again).
  • If you haven't done so already, you might need to add a Java SDK to your project. To do this go into File->Project Structure. Under Project Settings go into Modules and select the main module (should be the same name as your project). Then select Dependencies. If your Module SDK already lists Project SDK (1.6), then you don't need to do anything, otherwise click on New->JSDK. In here, browse to your Java SDK directory. You will then get a dialog stating Set up created SDK on project?, press OK. Note that you might need to restart IntelliJ after doing this to notice the changes
At this point, you should be able to build your Lift project, and create packages through Maven. To build your project, simply go to Build->Make Project (or do CTRL+F9). You can also go into Build->Build Artifacts to build your .war package for your website.

Setting up Jetty

By default, the Lift archetype ships with jetty, so to run jetty you would simply do mvn jetty:run in a terminal at the root of the project. We can however set this up as a Run/Debug configuration in Intellij

  • Go to Run->Edit Configurations
  • Click on the + button and select Maven
  • In Name put a name for your run configuration (I just put "Run Jetty")
  • In Working directory, select your projects root folder
  • in Goals, put in jetty:run
  • Since jetty uses the internal JRE, you will need to add extra parameters to allocate more memory to the JRE, so you will not get Out of Memory errors. Select the Runner tab and in VM Parameters put -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=1024m -Xmx1024M -Xss2M

Comments regarding Scala plugin

  • The Scala plugin in only being actively developed for the version 10.5 release of IDEA which is currently in "Early Access Program" (pre-release). If you have questions about stability or usability of specific versions, please feel free to ask in the Google group/mailing list.
  • To enable full syntax checking in the Scala plugin enable type aware syntax highlighting:
    Mac: Command + alt/option + shift + e
    Windows/Linux: alt + control + shift + e
    Note that the Scala plugin is still in heavy development and still has issues regarding its type aware syntax highlighting. If you get any errors, please report them at http://youtrack.jetbrains.net/issues/SCL
  • The Scala plug-in does not treat implicits as dependencies yet. If you're importing implicits into a page (e.g., DSLs, e.g., the LIft JSON DSL), the dependency will be grayed out as if unused. It's not. Don't remove it, or optimize imports on that file - you will get cryptic compilation errors

Using Built-in IDEA Build + Jetty Plug-in

Requirements and Notes

You will need IDEA 10.5 or later. This version includes a Jetty plug-in as part of the standard installation (though I don't know if this is part of the Community edition or requires the Ultimate edition). Since the Scala plug-in development has switched to this version, you should definitely have it anyway.

You will also need to download the Lift JAR files by hand. There is not (as far as I know) any kind of built-in dependency management in the IDEA Build process. To do this, you will need to go to the Lift Maven repository and root around through it looking for the correct versions of the correct JARs. Yes, this is kind of a pain. The Lift Maven repository can be found here: http://scala-tools.org/repo-releases/net/liftweb/

Create an "Artifact"

On the "Project Structure" dialog, create a new Artifact. I use "Web Application: Archive" which creates a WAR file. On the "Output Layout" subpanel, add all of the WAR contents - HTML, CSS, Jars, etc.

Create a "Run/Debug Configuration"

On the Run/Debug Configuration dialog, create a new configuration of type "Jetty Server -> Local". In the "Deployment" sub-panel, add the artifact that you created in the previous step. On the "Before launch" sub-panel, check "Make" and "Build 'myArtifact' artifact".

That's all there is. Now you can run or debug with a single push of a button. If you have the YourKit plug-in installed, you can also profile.

Using Ant Instead of IDEA Build

If you would rather use Ant to create the WAR file, rather than IDEA Build, skip creating the artifact. When creating the Run/Debug Configuration, on the "Before launch" sub-panel, check "Run Ant target...". If you need help creating the Ant build, you should probably read through the Ant documentation and/or ask your questions on an Ant specific mailing list.