Now i’m going to show you how to open the Maven project from Part 1 with Eclipse and what you have to care about when developing Scala/Java/Maven within Eclipse. It’s very easy to setup, but it took me a while so maybe it helps someone out there.
I’m using Eclipse version 3.5.2.
Before opening the Maven project with Eclipse, we need to download the M2Eclipse plugin and do some other adjustments to eclipse. M2Eclipse will handle all dependencies for our project and will build it automatically.
You can get the M2Eclipse-plugin from this update site:
http://m2eclipse.sonatype.org/sites/m2e
M2eclipse needs Eclipse to use the JDK as the JVM (the default setting is the JRE), so you have to alter the Eclipse.ini, inserting the path to your JDK.
Insert your JDK path before the vmargs. My Eclipse.ini looks like this:
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
org.eclipse.epp.package.jee.product
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vm
C:\Program Files\Java\jdk1.6.0_18\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
If you haven’t already done it, now it’s time to get the latest Scala Eclipse plugin. We need the latest nightly build, because the current stable release at the time of writing is Scala 2.7.7, but of course we need version 2.8 again. Fortunately, you don’t have to download the Scala compiler/SDK separately.
But i suggest to do that, as it’s a good Scala-training to use the Scala shell every now and then to try something out, without messing around with an IDE.
Download the latest Scala Eclipse plugin from the following update site:
http://www.scala-lang.org/scala-eclipse-plugin-nightly
The M2Eclipse plugin needs a user Settings.xml in order to work properly, so you have to create a settings.xml in the root of your local maven repository folder. Mostly it’s ${USER.HOME}/.m2.
A minimal Settings.xml could look like this (just change the local repository path):
<settings xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>
C:/Documents and Settings/Administrator/.m2/repository
</localRepository>
<interactiveMode>true</interactiveMode>
<usePluginRegistry>false</usePluginRegistry>
<offline>false</offline>
</settings>
Now you’re (finally) ready to import the project into Eclipse by choosing File\Import\Existing Maven Projects into workspace, browsing to the folder of the Maven project, and import it. If it’s the first time you use M2Eclipse, it will take some time to build the repository indices.
[EDIT: the following section could be obsolete, because you can fix missing source-folders with the Maven Build Helper Plugin as i described here]
Now that the project is in your workspace, you see that Eclipse shows some errors, and that there’s no package for the Scala class-folder in the project explorer – so Eclipse can’t see the Scala files. To fix that, right click on the project, go to Project Settings/Java Build Path/Source/Add Folder and add the scala source folder and all other folders that are absent (in the add folder view, always be sure to check only the folders named java or scala – else Eclipse confuses the package structure) . At the end it should look like this:
Now you need to tell M2Eclipse to update the project configuration. Do that by right-clicking on project, choosing Maven/Update Project Configuration. This will create the eclipse project information that’s needed by eclipse, which can also created by typing mvn eclipse:eclipse on the command line.
Hopefully all errors in the source files are now vanished.
You can run maven goals by right-clicking the project Pom.xml, choosing some goal – for example Run as/Maven test.

2 Comments
surfing for fun and exercise…
nice info…thank you..
I saw the edit you made to the Scala IDE wiki pointing to this blog entry … very interesting, thanks!
As you probably saw, the content there is horribly out of date and confusing. I think it would be an improvement if someone (ie. you, hint, hint
simply removed the existing content and replaced it with content derived from this article.
I’d be incredibly grateful if you’d do that, and so, I expect would the entire Scala+Maven using community.