Scala IDE for Eclipse compiler support

advertisements

What's the recommended way of getting Scala IDE for Eclipse to reference the scala-compiler.jar?

I encountered this issue while trying to develop a custom DSL that gets translated into Scala at runtime.

Using Scala parser combinators has been a sheer pleasure so far.

So now I have some generated Scala code that I need to compile and run. Scala supports this through the scala.tools.nsc.* package set.

However, the scala.tools.nsc package is not part of scala-library.jar, but rather a part of scala-compiler.jar.

As far as I can tell, the scala-compiler.jar is not installed as part of the bundle of Scala IDE for Eclipse (though it is part of the plug in), and I can't find any simple way to add support for it.

The only way around this seems to be manually adding a reference to the compiler jar, either from the Eclipse plugin directory or from a version downloaded directly from the web. Even if that works, however, it seems like a great way to run into problems down the road.

So, what's the best way to do this?

Cheers, Or


You're right that it's best to manually add the dependency rather than use the one that is bundled with Eclipse. If you're not using one already, look at a build system which does dependency resolution such as maven or ivy, or more in the Scala vein, sbt.

If you're not developing a plugin, then just use the normal dependency resolution in maven, or ivy or whatever. This is what you need for maven:

<dependency>
    <groupId>org.scala-lang</groupId>
    <artifactId>scala-compiler</artifactId>
    <version>2.9.1</version>
</dependency>

If you are developing a plugin, then you can use a similar dependency resolution, but if you're using maven, you'll probably want to look at Tycho.