2

When I try to build my Maven project in Eclipse, I'm getting this build failure message:

[INFO] Checking for transitive/resolved version mismatches.
[INFO] com.company.etc:artifact-name:
[INFO]     required: 1.5
[INFO]     resolved: 1.3

My POM file is requesting version 1.5 of this artifact, so that part is correct. But on the repository listed, versions 1.3, 1.4, and 1.5 are all available, with the correct maven-metadata.xml file in the root directory as well. Simply changing my POM file requirements to the older version is not an option, since I need the features in the newest version of the artifact.

I'm really stumped here. Is there anything I'm overlooking that might cause Maven to resolve a lower version number than what is actually available on the repo server?

carlspring
  • 31,231
  • 29
  • 115
  • 197
Matt Vukas
  • 3,225
  • 3
  • 26
  • 37
  • that's not build failure message, it's an info message. that is not failing your build as such. Also, picking lower version is standard maven behaviour in some cases - it uses closes-first matching, which will take the lower one if that is closest. Can you specify your pom? – eis Jul 10 '13 at 13:49
  • I guess I should specify - I have it set to fail the build if there are version mismatches. Is there anyway to have it pick the higher version? – Matt Vukas Jul 10 '13 at 13:52
  • Yes, by having explicit versions in pom files in correct places. But you would need to provide your pom details to tell more exact instructions. – eis Jul 10 '13 at 13:58
  • 4
    also, `mvn dependency:tree` output would be helpful – eis Jul 10 '13 at 13:59
  • mvn dependency:tree helped me figure it out, thank you! – Matt Vukas Jul 10 '13 at 17:46

1 Answers1

6

There are two possible solutions that I found for this issue:

The first one is to specify an exact version requirement, or "hard requirement" for a specific version of a dependency, as shown below:

<version>[1.5]</version>

instead of:

<version>1.5</version>

The second one is to use the mvn dependency:tree Maven command to see exactly what dependencies are being pulled in, and in what hierarchy. In my case, this solved my problem when I noticed that one dependency was actually pulling in an older version of another dependency, as a sub-dependency. Despite the fact that the sub-dependency was specified on its own elsewhere in the POM, Maven used the older version that was pulled in as a sub-dependency. Sounds confusing I know, but either way, mvn dependency:tree should show if a dependency is being pulled in unknowingly, or at an unspecified version.

Matt Vukas
  • 3,225
  • 3
  • 26
  • 37