Scala IDE for Eclipse is an open source project powered by Assembla
Assembla offers free public and private SVN/Git repositories and project hosting with bug/issue tracking and collaboration tools.
Viewing version 6 created about 6 years ago by Anonymous.
Using Maven with the Scala IDE for Eclipse
All Maven projects wishing to use Scala must first ensure that their project is set up and builds correctly on the command line. Please see the maven-scala-plugin for more details.
Support for Maven projects within the Eclipse IDE is provided by two alternative Eclipse plugin options:
You should never, EVER use a different plugin version from the version of scala you're using in Maven. The Scala IDE for eclipse is tied to a particular version of Scala and mismatched class versions can cause major issues on large projects.
What to use?
TO BE UPDATED
Several users report that q4e 0.81 works with SIE 2.7.4 and 2.8.0. Installing the Scala plugin first has been recommended. Start by creating a Maven project, then add the Scala nature to it.
m2eclipse appears to require that the Scala IDE implement an m2eclipse specific extension point otherwise it processes Scala projects incorrectly. Contributions from the community to support this would be welcome, but until then m2eclipse is not recommended. Josh Suereth writes in this thread as at 2009-04-09
"The maven-eclipse-plugin is currently "broken" in the sense that it won't pay attention to the source directories configured by the maven-scala-plugin." He advises "Remember though, using mvn eclipse:eclipse does not give the "Scala IDE for Eclipse" any chance to fix/edit its configuration. Most eclipse plugins assume they have full control over their configuration and when doing things through eclipse APIs, they have a chance to respond and tweak the project settings appropriately. This means that any bugs you run into in eclispe should be reproduced without using mvn eclipse:eclipse. This is why you should prefer eclipse plugins, rather than maven plugins, to do integration between Scala + Maven + Eclipse."
- Eclipse 3.4 is installed (3.5 can work with some more magic)
- Scala IDE for Eclipse plugin 2.7.5.final
- IAM previously Q4E
- Automatic Discovery of dependent artifacts
- Semi-Automatic setup of build paths
- Automatic Download of javadocs and sources for dependent artifacts
- Build/Test/Run inside or outside Eclipse
- Maven Dependency Management Interfaces (graphs and trees)
To get this set up, you should first checkout/create your maven project. Then run the Maven import command against the newly created/checked out project. Then click Right click the appropriate scala module projects and select the
Scala > Add Scala Nature menu item.
- Article to use scala and java using m2eclipse plugin and scala plugin http://mackaz.de/209
PENDING / TO WRITE
With Maven CLI
Or how to use maven-eclipse-plugin which emits Eclipse metadata
- Eclipse 3.5 (3.4 should work too)
- Scala IDE for Eclipse plugin 2.7.5.final - 2.8.0 nighly
- Maven 2.2.1 or 3.0 beta1+
- Generate Eclipse project files
- Import/refresh generated project files in Eclipse and edit/build/run/debug with no other modifications needed
- Still be able to build/test/run/package using the Maven CLI, independently of Eclipse
The workflow :
- First time
pom.xml(use instruction from maven-scala-plugin and complete with
pom.xmlfragment from bellow)
mvn eclipse:clean eclipse:eclipseto update eclipse meta-data
- configure M2_REPO classpath variable (for eclipse) to reference downloaded jar files. This is only needed once for the workspace, not for each project.
- from eclipse :
Window > Preferences > Java > Build Path > Classpath Variableto point to your
- or from shell : run
mvn -Declipse.workspace=<path to workspace> eclipse:configure-workspace( See eclipse:configure-workspace ) to add it automatically.
- Import project under eclipse (choose `File > Import... > Existing Projects into Workspace)
- after edition of
mvn eclipse:clean eclipse:eclipseto update eclipse meta-data
- refresh project under eclipse
- code under eclipse
- build the project with maven :
- from command line
- or from eclipse external tools, that call command line
- or from eclipse maven plugin (like m2eclipse)
Configure maven-eclipse-plugin :
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.8</version> <!-- see http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html for more information --> <configuration> <downloadSources>true</downloadSources> <downloadJavadocs>true</downloadJavadocs> <projectnatures> <projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature> <projectnature>org.eclipse.jdt.core.javanature</projectnature> </projectnatures> <buildcommands> <buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand> </buildcommands> <classpathContainers> <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer> <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer> </classpathContainers> <excludes> <exclude>org.scala-lang:scala-library</exclude> <exclude>org.scala-lang:scala-compiler</exclude> </excludes> <sourceIncludes> <sourceInclude>**/*.scala</sourceInclude> <sourceInclude>**/*.java</sourceInclude> </sourceIncludes> </configuration> </plugin>
For more configuration options or information take a look at the site of maven-eclipse-plugin
Configure source folders :
<build> <sourceDirectory>src/main/scala</sourceDirectory> <testSourceDirectory>src/test/scala</testSourceDirectory> ...
For more configuration options or information take a look at the site of maven POM Overview (Technical Project Descriptor)
If you have a mixed Java/Scala project with code into separated root directory (like src/(main|test)/scala and src/(main|test)/java) : org.codehaus.mojo build-helper-maven-plugin add-source generate-sources add-source src/main/scala add-test-source generate-sources add-test-source src/test/scala
For more configuration options or information take a look at the site of build-helper-maven-plugin.
For configuration of the compilation under maven see doc of maven-scala-plugin :
- for scala -depends of->java default configuration should work
- for java -depends of->scala bind 'compile' goal of maven-scala-plugin to phase
- for inter-dependency java scala (more longer to build because require 2 scalac pass).
Josh Sureth has a (on hold) Maven Scala integration project, ESMi, described as "The goal of ESMi would be to provide glue between the various means of creating a project: "Create Scala Project, then Enable maven dependency management, then fix build path", "Import Maven Project then add Scala nature then fix build path" or "Create Java Project, Add Scala nature, Enable Maven dependency management then fix build path" (my current choice)"
Choose two versions to compare, or click the link to view it.