IntelliJ IDEA, Scala and Continuous Builds (with some Mac OS X details)

My last post focused on how and why I picked IntelliJ Idea to be my Scala-IDE.
This short post illustrates on how I am using it.
The only things required are a working installation of Maven (2.x or 3.x for added flavor) and IntelliJ 10. I expect people reading this blog to be able to install both so I won’t spend time on this.

Note for Mac OS X and Maven:

For some reasons Idea wouldn’t pick up my Maven installation (even when using the overrides). Looks like this is a known problem. The fix is a little invasive but pretty simple:

  • Do ‘sudo su’ to become root
  • edit/create the file ‘/etc/launchd.conf’
  • insert ‘setenv M2_HOME <path-to-maven-install>’
  • restart

After starting the IDE we need to add the Scala Plugin. Go to Preferences -> Plugins and seelect the Scala Plugin, not the Scala Power Pack.
Scala plugin selected, not Scala Tools
After installing we can now continue to create a new Scala project. As we want to use Maven we will use the Maven archetype.
Create a new project with ‘Create project from scratch’, then select ‘Maven Module’. In the following screen select the org.scala-tools.archetypes:scala-simple-archetype and continue. The resulting project is a Maven-Java project and we need two things to turn it into the Scala project we wanted.
First thing to do is to change the Scala version in the pom.xml.

&lt;br /&gt;<br />  &lt;properties&gt;<br />    &lt;scala.version&gt;2.6.1&lt;/scala.version&gt;&lt;br /&gt;<br />  &lt;/properties&gt;<br />

Simply replace 2.6.1 with 2.8.1.
Now we need to turn the project into a Scala project. Right-click on the project and select ‘Add Framework Support…’
And adjust the following screen to look like this:

Select Scala and fill in the text fields

Add Scala Framework support

We are almost there.

The last remaining step in Idea is to turn off compilation from the IDE.
Create a run configuration and open it. Uncheck ‘Make’ in ‘Before Launch’.

Uncheck Make

Adjust build settings.

The only thing remaining is to start the continuous compile.
Open a terminal, cd to the directory with your new project (the one containing the pom.xml) and execute ‘mvn scala:cc’.
Maven will now watch the project for changes and compile everything that changes.

Now back to the 99.


About codepitbull
A nerd, a geek, a software developer. Oh, and married ;)

2 Responses to IntelliJ IDEA, Scala and Continuous Builds (with some Mac OS X details)

  1. v6ak says:

    There are more useful commands, for example mvn scala:cctest for testing or mvn scala:console for console, which can be integrated with JRebel.

    BTW: I’ve tried scala-archetype-simple, but it is really old. Fortunately, there is a new version (1.3) which can be added by Add archetype.
    You can watch new versions at .

  2. v6ak says:

    By the way, I’ve never needed to add framework support. It seems to be better to enable auto-import, which is an option availble when editing pom.xml.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: