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?
versions:use-latest-releases searches the pom for all non-SNAPSHOT versions which have been a newer release and replaces them with the latest release version. versions:update-properties updates properties defined in a project so that they correspond to the latest available version of specific dependencies.
For example, Eclipse has a pom. xml viewer with tabs at the bottom. You can click the tabs on the bottom to explore dependencies, then r click on one and say “exclude”. Eclipse will then prompt you as to where you want to add the exclusion.
How do you do this if the wrong dependency is a transitive dependency? By taking advantage of Maven's nearest definition logic, developers can override the version of a dependency by declaring it on the root pom. xml file.
Looking at the documentation for Maven range selections, I notice the comment:
Resolution of dependency ranges should not resolve to a snapshot (development version) unless it is included as an explicit boundary.
Unless the artifact version ends with -SNAPSHOT
, Maven is going to consider it a valid release build. As far as I know, -alpha1
has 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.
Maven 3 supports versioning for alpha, beta and snapshots as well
with the following order
alpha < beta < snapshot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With