Our warfile contains not the expected SNAPSHOT-Version of a jarfile, it contains an older release version via another dependency.
Simplified dependency:tree
war-x.x.x-SNAPSHOT
\- jar1-x.x.x-SNAPSHOT
+- jar2-x.x.x
| +- problemjar-x.x.x
+- jar3-x.x.x-SNAPSHOT
jar3-x.x.x-SNAPSHOT has a dependency "problemjar-x.x.y-SNAPSHOT" (newer version), but the war project build (and the dependency:tree) contains "problemjar-x.x.x" from "jar2-x.x.x".
For now, we "exclude" "problemjar-x.x.x" for "jar2-x.x.x".
But it would be nice to know the reason for this behaviour, IMHO the exclusion is just a workaround.
Notes:
edit: project structure
war and jar1 are children of one parent pom, the simplified dependency:tree is from the war project which has the jar1 project as a dependency. The others are normal/external dependencies, which applies to jar1 too as seen from the war project.
Maven does not take the newest version from the dependency tree.
It takes the nearest version, and in your case this is the first it encounters.
If you want to force Maven to take a specific version, it is better to use <dependencyManagement>
instead of exclusions.