How do i diagnose and fix classpath problems?

不想你离开。 提交于 2020-01-06 15:17:34

问题


I have a tycho project that includes xtend sources. One of my dependencies comes with an older version of JUnit that does not include all features that i need. I also have a dependency on JUnit 4.11. Tycho build is fine, but the xtend compiler (xtend-maven-plugin) seems to see the old JUnit version instead of the new one. How can i fix this?

[EDIT]

To clarify, this is how my dependencies look like:

Project A
|--Project B
|  |-- JUnit 4.8.2
|--JUnit 4.11

In the OSGi world of tycho, this is no problem. However, the xtend compiler resolves classes in Project A with JUnit 4.8.2 classes. I know this because the offending class is the annotation @Parameters, which gained the attribute "name" in 4.11. And this is exactly the offending part which keeps the xtend maven plugin from properly compiling. The Eclipse xtend tools seem to have no problems.


回答1:


There can be several problems here:

  1. Eclipse will put JUnit on your classpath when you start the tests. It needs that for it's JUnit runner to be able to talk to the running test process. This rarely causes problems but you should be aware of it.

  2. It you don't want a transitive dependency, add an <exclude> element inside of <dependency> in your POM. This of course only works for POM-first builds which seem rare in the Eclipse world.

  3. If you use Manifest-First builds, then you're dealing with OSGi. OSGi doesn't allow you exclude dependencies but it also isolates the different parts, so the Xtend compiler can use it's ancient version of JUnit without problems since your other plugins won't see that.

So the next step is to figure out where that dependency is coming from and excluding it properly.

To help you better, I need to know more about why you think that "the xtend compiler seems to see the old JUnit version".



来源:https://stackoverflow.com/questions/19998211/how-do-i-diagnose-and-fix-classpath-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!