Home > Back-end >  Select latest version from version range in Maven
Select latest version from version range in Maven

Time:10-14

I have dependency as follows:

<dependency>
  <groupId>com.google.http-client</groupId>
  <artifactId>google-http-client</artifactId>
  <version>[1.19.0,2.0)</version>
</dependency>

Is there any goal in maven which help me always select latest version i.e. 2.0 from above range explicitly and use it.

I am using maven 3.6.

Help appreciated

CodePudding user response:

First of all, your range does NOT include the version 2.0 because it is an open range (to include the version 2.0, you would need to write [1.19.0,2.0]).

Secondly, you can resolve version ranges with the versions maven plugin:

https://www.mojohaus.org/versions-maven-plugin/resolve-ranges-mojo.html

CodePudding user response:

I don't know of a way to do this in vanilla Maven, just by specifying a version pattern.

To achieve this, you could use the versions maven plugin. It allows you to provide a list of dependencies that should always use the latest version.

Your use case is more or less described in the documentation.

Alternatively, you could consider using a higher-level tool like dependabot. This would have the benefit of making this part of your CI process, rather than just a step in the application build, and orchestrate this behaviour across other technologies you might be using in your project.

  • Related