Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make maven use the latest release version within version range?

Tags:

maven-2

maven

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?

like image 478
snowindy Avatar asked Jan 21 '13 03:01

snowindy


People also ask

How do I get the latest version of Maven?

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.

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

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 override a transitive dependency version?

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.


2 Answers

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.

like image 160
Duncan Jones Avatar answered Sep 24 '22 03:09

Duncan Jones


Maven 3 supports versioning for alpha, beta and snapshots as well with the following order alpha < beta < snapshot

like image 33
yugandhar Avatar answered Sep 23 '22 03:09

yugandhar