I have a parent project contains a dozen child projects, one of the child projects use org.apache.httpcomponents:httpclient:jar:4.3.5
, which depends on org.apache.httpcomponents:httpcore:jar:4.3.2
.
However, the result version of httpcore
is resolved to 4.2.1 instead of 4.3.2.
The following is an extraction of the output when running dependency:tree
with debug option checked in Eclipse:
...
[DEBUG] Using mirror nexus (http://192.168.0.111:8081/nexus/content/groups/public) for apache.snapshots (http://repository.apache.org/snapshots).
[DEBUG] testArtifact: artifact=org.apache.httpcomponents:httpclient:jar:4.3.5:compile
[DEBUG] includeArtifact: artifact=org.apache.httpcomponents:httpclient:jar:4.3.5:compile
[DEBUG] startProcessChildren: artifact=org.apache.httpcomponents:httpclient:jar:4.3.5:compile
[DEBUG] manageArtifactVersion: artifact=org.apache.httpcomponents:httpcore:jar:4.3.2:compile, replacement=org.apache.httpcomponents:httpcore:jar:4.2.1
[DEBUG] Using mirror nexus (http://192.168.0.111:8081/nexus/content/groups/public) for apache.snapshots (http://repository.apache.org/snapshots).
...
It just shows replacement=org.apache.httpcomponents:httpcore:jar:4.2.1
, but it tells nothing about the reason of the replacement. The parent project's pom.xml uses quite a lot dependencies and even though I could try to remove those dependencies one by one and check the result, it would be quite time consuming. Is there any more effective way to debug the artifact replacement?
Here is almost the full log of the dependency:tree
from Eclipse with debug option checked.
From your log, you can find the lines:
Where you can see that the
javassist
andhttpcore
versions are dropped by certain transitive dependencies andjavax.activation
version is raised by one.This happens when more than one of your project dependencies are depending on the same library and have defined dependencies to different versions of that library. This can be annoying, since generally you cannot change how the parent POM or its dependencies are affecting the versions of your transitive dependencies.
The mediation rules from Maven docs are as follows:
However what you can do is manage the dependency versions yourself. This is called dependency management and as stated by the same docs:
Thus, you can just add:
into your own POM and this will always override whatever version are being defined for your transitive dependencies through dependency mediation.