In my maven project I use dependencies like this:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>[4.2.2, 5.0)</version>
</dependency>
Since the next major version (5.0) may change the API, I want my project to use the latest stable version available for branch 4.x.
This morning bug investigation told me this expression [4.2.2, 5.0) grabs any version available. In my case: 4.3-alpha1.
How to make maven use thelatest release version within version range?
Looking at the documentation for Maven range selections, I notice the comment:
Unless the artifact version ends with
-SNAPSHOT, Maven is going to consider it a valid release build. As far as I know,-alpha1has no special meaning to Maven. It’s just another random qualifier.I would strongly recommend you forgo the version range, anyway. Predictable builds should be the goal of any stable project and version ranges fly in the face of that.