0

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.

kutschkem
  • 7,826
  • 3
  • 21
  • 56

1 Answers1

0

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".

thSoft
  • 21,755
  • 5
  • 88
  • 103
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • The reason i think that is because i get compile errors for JUnit 4.11 API (things that compiled before but broke when adding the dependency on Project B. – kutschkem Dec 18 '13 at 08:30
  • The xtend-maven-plugin seems to not isolate the different parts, that is the source of my trouble in the first place. – kutschkem Dec 18 '13 at 13:33
  • xtend-maven-plugin exports all it's dependencies? File a bug; it shouldn't pollute the classpath of other plugins with JUnit. – Aaron Digulla Jan 08 '14 at 09:30
  • No... it just doesn't use the same dependencies as the tycho build. -> It fails because it loads JUnit 4.8 classes where it should load 4.11 classes. It would not influence the tycho build once the xtend compilation is done. – kutschkem Jan 09 '14 at 08:26
  • Ah. Then file a bug asking them to update the dependency :-) I think one of the problems with 4.8 is that it contains code from the hamcrest project. – Aaron Digulla Jan 09 '14 at 08:53