I'd like to start a debate about the new classpath validator. I saw it go past in the group, but didn't realise quite what the implications were. I saw that there was a discussion about this on scala-ide-user, but I wanted to specifically talk about what the behaviour of scala ide should be, so I'm starting another thread here.
So, some context: I upgraded to the latest version yesterday (good work all btw), and I started to run into problems. I have a maven project (with m2eclipse) which uses 1) scalariform (0.1.1) (2.9.1) and 2) scalatest (1.6.1) (2.9.1). Both of these have transitive dependencies on scala-library 2.9.1. So now I get the 'You have two versions of the library on your classpath' error. I install m2eclipse-scala, which removes the direct dependency, but not the transitive ones (bug, probably), so I'm still getting the error from scala-ide. So I remove the (2.9.2) library from the build path, and I get a warning (version of library is different etc). Everything compiles when I do project clean. I change a class, I get an error when I save: 'Cannot find Scala Library on the classpath: Verify your build path' (again a bug). I have to do a project clean every time I change a file now.
So, In upgrading my scala-ide, I've had to install another plugin (small impact) and change my dependencies in my pom (potentially large impact, always a pain to do).There are a number of points to make:1) I cannot upgrade the versions of scalariform & scalatest yet, because 2.9.2 versions don't exist for those libraries. This is a general problem, not specific to those two libraries.
2) It is notoriously hard to cleanly remove a dependency from maven. In my case, I can add exclusions to all of the libraries which have transitive dependencies on the scala-library. But this also means that if I'm creating a main which is runnable with just a jvm then the scala-library won't get included in the dependencies.
3) mucking with poms is notoriously dark magic, not everyone (including me) understands exactly what scope means what. And not everything works in all cases (for instance deploying to Tomcat from within Eclipse deploys any jars with provided scope, even though it shouldn't do).4) This problem exists with java, but isn't as 'in your face'. Mainly because the java rt.jar isn't a maven dependency, but comes with the jdk/jre. With java, you select the jdk you want to use as an execution environment: You can still get problems with usage of methods which don't exist on the target jvm because you've compiled it with a newer jvm with --source. I have been bitten by this before with java, hence the reason for the existence of http://maven.apache.org/plugins/maven-enforcer-plugin/usage.html which checks exactly that.5) I could fix this by having a dependency in maven on the specific version which is used in the plugin in eclipse, but I actually can't find it, and it may break existing codeSo there are a number of options:1) Persuade all of the library writers to not include transitive dependencies on the scala-library. I don't believe this is possible or realistic, even though it makes life 'easier' for everyone.2) The classpath validator could assume that the libraries are backwards compatible. So if I have a scala-ide which expects a scala library of 2.9.2 and I add a 2.9.1 afterwards in the classpath, this is acceptable. The other way around won't be. This would mean I have to rearrange my build path in eclipse to have the built-in scala library before the one in the maven dependency. Impact on the project? Not sure.
3) Downgrade the classpath validator to a warning.4) Have an option which switches off the validator, with a popup when you do which says 'Are you sure you know what you're doing, etc?'. This could be done on a per-project basis.
Personally, I would prefer at least option 3 and in addition option 4, because I don't like warnings I can't configure away. I like my projects to have 0 warnings. I can do the required work if necessary.Please don't take this email as a criticism, it isn't meant to be one. I think the classpath validator gives useful information, but as always, the real world (i.e. maven and dependency management) intervenes.
Thanks a lot for taking the time of writing this down, your feedback is *truly* appreciated.
Another user in the scala-ide-user mailing list just reported a similar issue, and he fixed that by
installing the latest version of m2eclipse plugin. Here is the link to the discussion
https://groups.google.com/group/scala-ide-user/browse_thread/thread/4ef0597a0190dae4?hl=en
I wonder if you are already on the latest version of m2eclipse and, if not, if you could check if the
problem goes really away when using the latest m2eclipse. It would be definitely useful to know.
Cheers,
Mirco