Search code examples
javamavendependenciespitest

maven got old junit dependency in ./m2/repository from nowhere


I have java-maven project

mvn instal

gets .m2/repository/junit/junit/3.8.1 always, after I delete it. I don't understand where it comes from.

I tried dependency-tree: mvn dependency:tree -Dverbose | grep "junit" But it prints only 5.4.0 junit which I really use in my project.

[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.4.0:test
[INFO] |  +- org.junit.platform:junit-platform-engine:jar:1.4.0:test
[INFO] |  |  \- org.junit.platform:junit-platform-commons:jar:1.4.0:test
[INFO] |  \- org.junit.jupiter:junit-jupiter-api:jar:5.4.0:test
[INFO] |     \- (org.junit.platform:junit-platform-commons:jar:1.4.0:test - omitted for duplicate)
[INFO] \- org.junit.jupiter:junit-jupiter-params:jar:5.4.0:test
[INFO]    \- (org.junit.jupiter:junit-jupiter-api:jar:5.4.0:test - omitted for duplicate)

I want to understand why maven download old junit always, how can I debug it? It's not in any pom.xml file, if it's transitive dependency why it's not shown in dependency-tree. The real problem is that I am trying to run PItest in IDEA, and it says that I have old junit vertsion 3.8.1. But I don't really use it in my project.


Solution

  • mvn dependency:tree doesn’t show plugin dependencies.

    You need to check your plugin dependencies. You can do it using mvn dependency:resolve-plugins as described here: https://maven.apache.org/plugins/maven-dependency-plugin/resolve-plugins-mojo.html