Scala IDE for Eclipse compiler support - eclipse

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.

It's simple: The Scala IDE for Eclipse comes with a Library called "Scala Compiler". Just select "Build Path > Add Libraries ..." from your Scala project's context menu and select the "Scala Compiler" library from the dialog.

Related

How do I run SBT from within Eclipse?

So far I've been running IntelliJ IDEA Community Edition for my Scala projects, but as my projects are expanding in complexity, I stumble upon more and more roadblocks with the IDE.
Like for example the simple fact that IDEA doesn't allow for web-development or Java EE development what so ever, which means using the Play Framework or TomEE in Community Edition leads to nothing but dead ends and frustration.
The only reason I switched to IDEA in the first place, is because of its excellent plugin system, allowing me to run SBT seamlessly as the primary scala compiler and library downloading tool with ease.
Searching around on Google, however I can only seem to find mentions about the eclipse plugin for sbt, that makes an sbt project Eclipse friendly, which is the exact opposite of what I'm really looking for.
I'm not willing to spend €89 per year for a student licence after all the pain it's put me through so far...
So my question is; is there a plugin for Eclipse that allows me to use SBT the same way as in IDEA? Or am I forced to go through the console?
There may be some movement in this direction in the future, but for now there is no such plugin.
Currently there is no Sbt plugin for Eclipse. Depending on your use-case, you could:
use the Eclipse builder
Pros: proper integration (error markers in Problems and editors, cancelation, progress reporting)
Cons: may get out-of-sync with the Sbt build file (when adding a dependency, for example), doesn't handle anything other than Java and Scala (like Play templates or route files)
use Sbt on the command line (make sure to disable auto-building in Eclipse)
Pros: can handle complex builds, classpath is always up to date
Cons: no integration (see above)
use Activator
Same Pros and Cons as Sbt, but with a pretty UI
We are working on an sbt-server plugin for Eclipse, which will delegate the build to an external Sbt process without giving up the convenience of integration. We hope to have something out towards the end of this year.
I think the main problem you are trying to solve for is too have sbt jar dependencies show up and get used natively by your eclipse project. You can do that with the IvyIDE plugin (which is found in the eclipse marketplace).
If you have that installed (and the eclipse plugin for sbt) then this closes the gap between systems.
To enable:
type the {sbt deliver-local} command from your terminal. This adds an ivy xml in your project's target directory
right click on your project. Choose the Ivy -> enable Ivy dependency management option
go into your projects properties. Highlight the Ivy property. Click the new button and navigate to the ivy xml file in your projects target directory.
Now your eclipse compiles off of your sbt managed dependencies and now you are doing everything you want except actually running sbt from within eclipse (which you only have to do now when you are changing dependencies)

IntelliJ 404 scala lang

Ok, I need some help in setting up a Scala project with IntelliJ, I have download and installed the project successfully, but i have had issues when it comes to installing the Scala compiler itself, WHen i go to configure a new Scalaa project and choose to set the Scala home, I choose the download Scala option and i get the following error "downloading failed, connection failed with error 404: http://www.scala.lang.org/downloads.distrib/files/scala2.10.0+RC2.tgz" i have tried downloading the things, such as primefaces and jSF through intelij, and they all work fine, any suggestions?
Download Scala manually and just select proper directory in new project window.
http://www.scala-lang.org/download/
You should be using SBT to define and build your project. Among other things, it handles retrieving the Scala compiler and libraries. IDEA is similarly self-contained as far as its Scala plug-in's internal Scala compiler is concerned. By using SBT and IDEA (see below for connecting the two), the only thing not covered is a Scala REPL for use outside of either SBT or IDEA. If you're using a Mac, Homebrew includes a Scala formula. Because SBT retrieves the Scala compiler and libraries for the version of Scala you specified, everything is self-contained.
By far the best way to build and maintain IDEA project definitions for Scala projects is with the sbt-idea plug-in for SBT. Once you install that plug-in, which is trivial, you simply use the gen-idea SBT task it provides. When your dependencies change, you run gen-idea again to update the project.

aaspectj - installation, ide and in between

I'm fairly new to aspectj. and actually need to use it because a feature in spring needs it in order to work.
One thing i don't get. i see that the installation of the aspectj is via eclipse.
so apparently post installation - all my src code and jars are still the same.
so what exactly am i installing? I mean, my project is comprised of jars + .class files so what difference does it make if i install a plugin in my IDE?
p.s I tried to install it but all the installation of aspectj are through maven and I Don't use maven.
there are kind of supporting tools for eclipse that ease aspectJ development (e.g. it shows you weaved pointcuts etc).
AspectJ itself has several options of how to "enrich" your code. You can use compile-time weaving, which modifies your class-files. or you use load-time weaving, in which case aspectj modifies the bytecode during startup of your application.
either way, after weaving, your code depends on the aspectJ-runtime library, so you need this in your classpath too.
If you use maven, you add aspectj-stuff to it, if you dont, you add it to eclipse itself (which is the plugin for, i guess). just install ADJT and you are up and running.

How to use just one scala library for maven/eclipse/scala

I have configured a project to use scala/maven/Eclipse. Because I need a scala library on the build path and scalatest also uses its own scala library I receive this warning :
More than one scala library found in the build path, all with
compatible versions. This is not an optimal configuration, try to
limit to one scala library in the build path.
I don't think I can remove this warning as I need both libraries - one for Maven, the other for Eclipse. This doesn't seem to be causing any problems so will I just have to accept it? Is there an alternate configuration which uses just one scala library for Maven & Eclipse?
If I remove the scala library from the project I receive the error:
Cannot find Scala library on the classpath. Verify your build path!
For some reason Eclipse requires the scala library to be on the build path even though it is already available as a Maven dependency.
There is nothing to worry about. Eclipse warns you that you have several scala-library.jars on your classpath, but as long as they are the same version, it doesn't matter.
If one of them diverged (for instance, by bumping the Scala version number in your pom file), you'd be in trouble: depending on the classpath order, the IDE will pick up classes from one or the other, and you might get different results when building on the command line.
Coming back to your setup, you could
remove the Scala Library classpath container from your Eclipse projects, leaving just the jar that maven adds.
ignore the warning
Venturing a guess here, are you using the Eclipse Indigo pre-installed with Scala 2.9 and the corresponding Scala plugin? If that's the reason you need to use that library, perhaps consider using Eclipse Juno? That's what I use and it works quite well with both the milestone and the nightly builds

What is a "build manager" for scala in the scala ide extensions for Eclipse?

In Eclipse in Preferences -> Scala -> Compiler -> Build manager, I can select a "buildmanager." What is the difference between "refined" and "sbt"?
Also, is this some method to integrate an sbt build file into the Eclipse IDE?
ScalaIDE has two build managers, basically they are interfaces between the eclipse model and the scala compiler, they have to do things like work out which resources need re-compiling and how that affects dependent code. Refined is a refined version of the original interface and sbt is, well, sbt.
SBT is the default now, and I expect refined will go away at some point.
Unfortunately the build manager is very much under the hood. There is no real eclipse project->sbt integration yet. There is an eclipse plugin for sbt which allows you to generate eclipse project files but no tight integration from an eclipse project to sbt akin to IvyDE or m2e.
You can use sbt deliver-local to create an ivy file of dependencies, and use IvyDE to keep your classpath containers up to date - that's about as good as it gets at the moment.
I wouldn't be surprised to see this situation improve though - check out the roadmap.