Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should Maven dependency version ranges be considered deprecated?

Given that it's very hard to find anything about dependency version ranges in the official documentation (the best I could come up with is http://docs.codehaus.org/display/MAVEN/Dependency+Mediation+and+Conflict+Resolution), I wonder if they're still considered a 1st class citizen of Maven POMs.

I think most people would agree that they're a bad practice anyway, but I wonder why it's so hard to find anything official about it.

like image 607
Kutzi Avatar asked Aug 23 '11 20:08

Kutzi


People also ask

What happens if we don't specify version in pom?

Each maven dependency defined in the pom must have a version either directly or indirectly for example, through dependencyManagement or parent. That being said, if the version is not given, then the version provided in the dependencyManagement or the parent pom will be used.

What happens if you don't specify a version in Maven?

Maven won't allow any other either. Build will fail if version is not found.

Is version tag mandatory in pom xml?

Elements of pom. xml file. modelVersion – This element is mandatory and its value should be 4.0. 0 which can support both versions of Maven 2 and 3. groupID – This element must be unique as it specifies the project id.

How do I exclude a specific version of a dependency in Maven?

Multiple transitive dependencies can be excluded by using the <exclusion> tag for each of the dependency you want to exclude and placing all these exclusion tags inside the <exclusions> tag in pom. xml. You will need to mention the group id and artifact id of the dependency you wish to exclude in the exclusion tag.


1 Answers

I don't know why you think that version ranges are not documented. There is a concrete abstract in the Maven Complete Reference documentation.

Nevertheless - a huge problem (in my opinion) is that it is documented that "Resolution of dependency ranges should not resolve to a snapshot (development version) unless it is included as an explicit boundary." (the link you provided) but the system behaves different. If you use version ranges you will get SNAPSHOT versions if they exists in your range (MNG-3092). The discussion if this is wanted or not has not ended yet.

Currently - if you use version ranges - you might get SNAPSHOT dependencies. So you really have to be careful and decide if this is wanted. It might be useful for your own developed depedencies but I doubt that you should use it for 3rd party libraries.

like image 94
FrVaBe Avatar answered Oct 21 '22 18:10

FrVaBe