How to use just one scala library for maven/eclipse/scala
Asked Answered
H

2

12

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.

Hola answered 3/12, 2012 at 11:31 Comment(3)
it might be possible that the project you loaded contains several jars in the classpath, which contains the scala library. (happened to me a while back, saw this exact message... including jars more carefully, i.e. using the "thin" jars and not the stand-alone "fat" jars solved the problem...)Niche
why do you need different scala libraries between maven and eclipse?Martino
if maven is okay with only one scala-library, then you have no problem. use the maven eclipse plugin mvn eclipse:eclipse to generate the eclipse project files for the fixed project setup.Niche
P
10

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
Phillis answered 3/12, 2012 at 16:20 Comment(1)
Are you using 2.0.2? You are probably experiencing this issue, fixed in 2.1.0-milestone 2.Phillis
G
0

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

Gadoid answered 3/12, 2012 at 15:28 Comment(1)
I installed scala plugin 2.9 seperately over Indigo. I cannot use Juno.Hola

© 2022 - 2024 — McMap. All rights reserved.