Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 990
blue-sky Avatar asked Dec 03 '12 11:12

blue-sky


1 Answers

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
like image 80
Iulian Dragos Avatar answered Nov 09 '22 22:11

Iulian Dragos