views:

19

answers:

1

Hi folks,

it might be a duplication, but in eclipse, how can I deal with various dependency versions of the same library in my local maven repository ?

The problem is that dependency versions specified in pom definition are the libraries I need to use (they have sources/javadoc available etc.), but maven puts all the available library versions on classpath, so that if I ctrl+shift+T or step into some class which belongs to that dependency, it might be the one without sources/javadoc, the one not declared in pom definition but in local maven repo. There is no way of setting up precedence.

There is a feature "Remove from history" right in the pup up window (Ctrl+shift+T), but it is practically useless, doesn't work.

+2  A: 

The problem is that dependency versions specified in pom definition are the libraries I need to use (they have sources/javadoc available etc.), but maven puts all the available library versions on classpath (...)

No, that's not true. Maven puts on the class path what you tell him to put on it.

(...) so that if I ctrl+shift+T or step into some class which belongs to that dependency, it might be the one without sources/javadoc, the one not declared in pom definition but in local maven repo.

With Eclipse, when you Open Type, Eclipse simply searches for the type in the classpath of all projects in the workspace. So if you have a project A that has foo-X.jar on its classpath and a project B that has foo-Y.jar on its classpath and if both contain the Bar type, searching for Bar would list both versions.

But Eclipse doesn't search in JARS that are not defined as dependencies of projects in your worskpace, it doesn't search in all JARs of your local repository. And this is not really a Maven or m2eclipse specific issue.

That said, the only way I know to restrict the search to, say the dependencies of project A only, would be to define a Working Set using the menu under the upper right arrow:

alt text

Pascal Thivent
This is the only intuitive way Eclipse *can* work, as far as I can see - otherwise, should "Open Type" just look in jars used by the current project, or jars used by the project that 'owns' the currently visible file?
SimonJ
Thanks Pascal, you're right, I completely forgot about the other working sets, I stopped using working sets long time ago and there were accidentally all the dependency versions listed as I had in local maven repo, so it misled me. I haven't even noticed the top right menu. Cheers
lisak