Not seeing latest dependency version when I run versions:display-dependency-updates - maven

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?

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.

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

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

Related

mvn clean install pulls in old snapshot version that don't exist

I am trying to compile my code and with the latest version. I see that the old SNAPSHOT version is being picked up as well when I check the .war file. I ran the dependency:tree and checked if it had anything to do with it but nothing came up which said so.
Is there a way I can change the pom.xml to ensure this doesn't happen.?
Run the build with -U and you get the newest SNAPSHOT versions.

Maven dependency version, use one version or the other

I am building a Dev version of my app that have multiple dependencies. All dependencies are set up as 1.0.0-SNAPSHOT.
However, as i build some of the dependencies, the version would be similar to “DEV-SNAPSHOT”. What I need is the ability to pass in that version(DEV) and have each dependency pull it if that version exist, otherwise pull 1.0.0-SNAPSHOT. Everything I have found gets me both of they both exist-I only want those that have a dev to pull dev and the others to pull 1.0.0.
Is that possible?
If exist version A:
Pull version A
Else:
Pull version B

Not specifying Gradle minor version

Using gradle:
Is it possible to set the dependencies such that minor versions are auto upgrading? For instance, I would like gradle to automatically pick the latest guava 11 minor version.
Adding
compile 'com.google.guava:guava:11'
unless of
compile 'com.google.guava:guava:11.0.2'
do not seems to work.
The syntax to use is "11.+" if you want any minor revision above 11.0.0.
If you want for example 11.0.2 but not 11.1.0, you can use "11.0.+".
Using "11+" will probably also find 12.0.0 and above, so would not work as well.
This is mentioned in the Gradle user's guide, where it's referred to as a dynamic version.
Replace it with:
compile 'com.google.guava:guava:11.+

Difference between mvn and mvn3 command

I have latest version of maven installed which is 3.0.4. A test at command line with mvn -version results in confirming this.
For all my maven commands I am using mvn but on several occasion on the internet I have seen people using mvn3 instead what is the difference between the two commands and why I am unable to use mvn3?
Seems like (according to How do I install Maven 3?), default installation of maven 3 on Ubuntu uses mvn3 symlink to mvn.
I can't find mvn3 command neither in 3.0.3 nor in 3.0.4. I believe mvn3 is only used to emphasize that maven 3 should be used as opposed to maven 2 (still popular). These two versions are significantly different so it's worth to make sure newer is used.

Maven archetype fetching old version

I am generating a maven project using an archetype that I've uploaded to the central repository.
mvn archetype:generate \
-DarchetypeGroupId=org.opencoweb \
-DarchetypeArtifactId=coweb-archetype
The latest version is 0.8.3.1, but the version I get instead is 0.8.3. I have cleared out my cache ~/.m2, and running the above command stil downloads 0.8.3 instead of the latest version. Does anyone know why? Did I forget to specify something when I uploaded/created the 0.8.3.1 module? I uploaded the module earlier this month (Oct 3), and according to http://search.maven.org/remotecontent?filepath=org/opencoweb/coweb-archetype/maven-metadata.xml, the "latest version" is 0.8.3.1.
Edit:
I can download the latest 0.8.3.1 version, but only if I specify -DarchetypeVersion=0.8.3.1. However, this is clearly undesirable.
check this answer. maybe the Latest-part is helpful for your needs.
https://stackoverflow.com/a/13058666/1602465

Resources