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

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

Related

Different version of scala lib in build path and scala-ide

I have two versions of scala (2.11.4 and 2.10.4). Currently I work on project based on scala 2.10. I've changed version in project properties but ide still complains about it:
The version of scala library found in the build path (2.10.4.) is different from the one provided by scala IDE (2.11.4.). Make sure you know what you are doing.
I am using
Scala IDE build of Eclipse SDK
Build id: 4.0.0-vfinal-20141216-1226-Typesafe
Project config:
Any idea how fix that?
That complaint is a warning, not an error; all is fine. I suspect the message is mostly left over from when scala-ide used to only support working with a single version of scala in a single install (which was only fixed in 4.0)
Yes, you can use the multiple scala version support, as described in this blog post.
Once correctly configured, as you showed in the image, this is just a warning and therefore safe to ignore.

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.

Scala IDE for Eclipse compiler support

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.

Scala Eclipse IDE - strange behavior

I am giving a try to Scala Eclipse IDE after a very long time. I installed Eclipse and the said Scala plugin only a while ago, but I am unable to get stuff working. In all of the Scala files, I get the errors like following (See the tooltip):
This project uses Gradle for building, and I also have the latest version of Groovy plugin installed. Please help me get this thing working. Thanks.
Edit:
Thank you, everyone. The problem was solved. It appears there was a problem with my Scala plugin installation. A complete reinstall of everything (including Eclipse) helped. Also, this time I did not install the Groovy plugin.
I don't know which version of Eclipse / Scala-IDE you're using, but there are two reasons I know this sometimes happens:
1) You don't have JDT weaving for Scala installed.
The scala-ide uses aspects to weave in code into the JDT compiler. If you don't have this installed, this may cause the Scala files to be seen as Java files.
2) If, somehow, the Java Source File content type includes *.scala. In fact, it should be Scala Source File. If this is the case, you should remove the *.scala from the Java Source File content type.