0

I am using Eclipse Oxygen 1a, with the Scala IDE installed, and have imported a legacy project into it. I have been updating dependencies and trying to resolve various warnings and conflicts, but have come across one that has me stumped.

In the code there is the following:

val messageMatcher = equalTo(expectedMessage)
messageMatcher.describeMismatch(item, mismatchDescription);
messageMatcher.matches(item.toString)

Now when I click on "equalTo" it jumps to the the source for Matchers.class in the hamcrest-all-1.3.jar. The describeMismatch line however shows the error:

value describeMismatch is not a member of org.hamcrest.Matcher[String]

When I click on the next line "messageMatcher.matches" it tries to open the Matcher.class source from the junit-4.10-sources.jar.

Now I am aware that there is a conflict between junit 4.10 and hamcrest since junit has an older version of hamcrest as a transitive dependency, but the part that's baffling me is that I'm not using junit 4.10 anywhere afaik. When I run:

$ mvn dependency:tree

There is no mention of junit 4.10. I also did a grep on the entire directory structure and there is no mention of junit 4.10 in any file contained in the project.

If I delete junit 4.10 from my local repo the hamcrest error above goes away, but is replaced by an error saying

Project 'myproject' is missing required library: '~/.m2/repository/junit/junit/4.10/junit-4.10.jar'"

I am baffled...


Edit:
"Now I am aware that there is a conflict between junit 4.10 and hamcrest since junit has an older version of hamcrest as a transitive dependency, but the part that's baffling me is that I'm not using junit 4.10 anywhere afaik."

Momus
  • 385
  • 2
  • 11
  • 1
    Possible duplicate of [Getting "NoSuchMethodError: org.hamcrest.Matcher.describeMismatch" when running test in IntelliJ 10.5](https://stackoverflow.com/questions/7869711/getting-nosuchmethoderror-org-hamcrest-matcher-describemismatch-when-running) – Abhijit Sarkar Nov 24 '17 at 19:03
  • 1
    Literally the first line of that "possible duplicate" says "I'm using JUnit-dep 4.10 and Hamcrest 1.3.RC2.". I explicitly state that I AM NOT using junit 4.10 and can't figure out where it's coming from. – Momus Nov 24 '17 at 19:06
  • You've not declared JUnit specifically, doesn't mean you're not using it. The error shows otherwise, doesn't it? – Abhijit Sarkar Nov 24 '17 at 19:09
  • Yes, and that is the actual question I've asked: How can I figure out where this junit 4.10 dependency is coming from? The mvn dependency:tree does not show it yet if I delete junit 4.10 from the repo I get an error saying it is missing. – Momus Nov 24 '17 at 19:20
  • ok. Since the problem is with the classpath of your application, we can only speculate without a [mvce](https://stackoverflow.com/help/mcve) – Abhijit Sarkar Nov 24 '17 at 19:23
  • @Momus Could I please see the `import` statements related to JUnit you have in your test? Is it a Java or Scala test? We need to understand what pulls the dependency to JUnit 4. – Alexandre Dupriez Nov 25 '17 at 12:03
  • @Momus Does it only occur in Eclipse, or using command line Maven as well? – helospark Nov 26 '17 at 20:35

0 Answers0