1

I am trying to update dependencies in my java mvn project to latest version. When I run below command I see latest versions displayed, but I see different versions in central repository.

mvn versions:display-dependency-updates -DskipTests=true --update-snapshots install

For example, when I ran above command I got this for commons-collections

commons-collections:commons-collections ............ 3.2.1 -> 20040616

But when I browse it in the central repository - commons-collections:MVN Repo, I see many updates after 20040616

Can someone clarify which is the latest version and MVN command to get the latest?

Maria
  • 1,161
  • 3
  • 12
  • 21

3 Answers3

1

Unfortunately Maven does not know when the dependency was published, it just compares text.

In your case, the latest version of commons-collections:commons-collections is 3.2.1, but if you compare the text, 20040616 is bigger.

So basically 20040616 > 3.2.1 becuase it thinks 20040616 is a major version and it is bigger than 3.

Read more here: https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN402

Andras Szell
  • 527
  • 2
  • 13
1

The display-dependency-updates command assumes that versions are numbered according to a very specific <Major>.<Minor>.<Incremental>-<Qualifier> structure, per the versions-maven-plugin Version Number Rules. It determines "newest" by sorting according to those criteria, and not via some sort of timestamp. When using dependencies that follow different rules, it's not likely to be able to tell you which version is actually newer. Sadly, this makes display-dependency-updates not nearly as useful as one might hope, but I still find it useful as a starting point to check and see what dependencies may need to be updated.

1

I generally use http://mvnrepository.com to find the latest version of an artifact, while you have used http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22commons-collections%22%20AND%20a%3A%22commons-collections%22. However, I see similar problems. 20040616 is not the date of the artifact, it is the version of the artifact. Since 20040616 is greater than 1, 2, 3, or 4, version 20040616 will always be viewed as the latest version. It would appear that this artifact should be removed from the repository since it does not obey the numbering rules. I have seen a few other problems like this in the repository, but I'm not sure who to contact to get it corrected.

http://www.mojohaus.org/versions-maven-plugin/display-dependency-updates-mojo.html description of display-dependency-updates

Bradley Ross
  • 445
  • 2
  • 8