froethen
froethen

Reputation: 2173

Maven check for updated dependencies in repository

Is there a Maven plugin that allows you to check if there are newer versions of dependencies available in the repository?

Say, you are using dependency X with version 1.2. Now a new version of X is released with version 1.3. I'd like to know, based on the dependencies used in my project, which dependencies have newer versions available.

Upvotes: 216

Views: 85715

Answers (8)

Alexis
Alexis

Reputation: 76

You can use MvnCheck, a command line tool, which is standalone unlike the Versions Maven Plugin. It also works with Gradle projects.

Output example:

2 build file(s) found, checking for artifact updates

my-gradle-project\build.gradle
[COMPILE ONLY] com.google.guava:guava 31.0-android -> 31.1-android
1 artifact update(s) available

my-maven-project\pom.xml
[DEPENDENCY] org.apache.commons:commons-lang3 3.10 -> 3.12.0
[BUILD PLUGIN] org.apache.maven.plugins:maven-compiler-plugin 3.10.0 -> 3.10.1
2 artifact update(s) available

2/2 build file(s) checked, 3 artifact update(s) available

Disclaimer: I am the author of MvnCheck.

Upvotes: 0

damndemon
damndemon

Reputation: 346

I might be a bit late to join the party but a more clear way to get more readable html file or a xml file as report which can be taken for further automation using:

mvn versions:dependency-updates-report

This report plugin not just shows more comprehensive details on updates but also has options to update to latest versions. You can find the documentation for it to use various parameters.

Upvotes: 2

Pascal Thivent
Pascal Thivent

Reputation: 570345

The Maven Versions plugin and it's display-dependency-updates mojo are what you're looking for:

mvn versions:display-dependency-updates

Here is what the output looks like:

[INFO] ------------------------------------------------------------------------
[INFO] Building Build Helper Maven Plugin
[INFO]    task-segment: [versions:display-dependency-updates]
[INFO] ------------------------------------------------------------------------
[INFO] [versions:display-dependency-updates]
[INFO]
[INFO] The following dependency updates are available:
[INFO]   org.apache.maven:maven-artifact ........................ 2.0 -> 2.0.9
[INFO]   org.apache.maven:maven-plugin-api ...................... 2.0 -> 2.0.9
[INFO]   org.apache.maven:maven-project ....................... 2.0.2 -> 2.0.9
[INFO]   org.codehaus.plexus:plexus-utils ....................... 1.1 -> 1.5.6
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17 seconds
[INFO] Finished at: Fri Aug 15 10:46:03 IST 2008
[INFO] Final Memory: 10M/167M
[INFO] ------------------------------------------------------------------------

Upvotes: 360

Saurabh Dedhia
Saurabh Dedhia

Reputation: 141

The ideal way to do it is to set dependency versions as properties in pom.xml and then running the below command to get the updated versions for your specific/custom dependencies.

<properties>
    <java.version>1.8</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <skip.tests>true</skip.tests>
    <spring-cloud-gcp.version>1.2.3.RELEASE</spring-cloud-gcp.version>
    <spring-cloud.version>Hoxton.SR6</spring-cloud.version>
    <spring-cloud-stream-schema.version>2.2.1.RELEASE</spring-cloud-stream-schema.version>
    <confluent.version>5.5.1</confluent.version>
    <avro.version>1.10.0</avro.version>
    <janino.version>3.1.2</janino.version>
    <swagger.version>2.9.2</swagger.version>
    <google-cloud-logging-logback.version>0.118.1-alpha</google-cloud-logging-logback.version>
    <spring-cloud-stream-binder-kafka.version>3.0.6.RELEASE</spring-cloud-stream-binder-kafka.version>
</properties>
mvn versions:display-property-updates


[INFO] The following version properties are referencing the newest available version:
[INFO]   ${avro.version} .............................................. 1.10.0
[INFO]   ${spring-cloud-stream-schema.version} ................. 2.2.1.RELEASE
[INFO]   ${janino.version} ............................................. 3.1.2
[INFO] The following version property updates are available:
[INFO]   ${spring-cloud-gcp.version} .......... 1.2.3.RELEASE -> 1.2.5.RELEASE
[INFO]   ${google-cloud-logging-logback.version}  0.118.1-alpha -> 0.118.2-alpha
[INFO]   ${spring-cloud-stream-binder-kafka.version}  3.0.6.RELEASE -> 3.0.8.RELEASE
[INFO]   ${confluent.version} ................................. 5.5.1 -> 6.0.0
[INFO]   ${swagger.version} ................................... 2.9.2 -> 3.0.0
[INFO]   ${spring-cloud.version} .................... Hoxton.SR6 -> Hoxton.SR8
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.572 s
[INFO] Finished at: 2020-10-06T09:35:08-07:00
[INFO] ------------------------------------------------------------------------

Another way to achieve this is by executing the command mvn versions:display-dependency-updates but the problem I face with this approach is that it also shows me updates for the nested dependencies which are not too useful for me.

Upvotes: 14

muttonUp
muttonUp

Reputation: 6717

In projects with a large number of dependancies, you sometimes keep your versions in a properties section.

    <properties>
        <assertj.version>3.15.0</assertj.version>
        <aws-sdk.version>1.11.763</aws-sdk.version>
        <cxf.version>3.3.6</cxf.version>

In the case where you are only interested in updates to those versions, you can use the following command

mvn versions:display-property-updates

This gives a more condensed view and only returns the versions you need to update in the properties section.

Upvotes: 50

Robert Reiz
Robert Reiz

Reputation: 4433

The VersionEye Maven Plugin is doing the same: versioneye_maven_plugin.

VersionEye can notify you about new versions on Maven Repositories, too. It is a language agnostic tool and beside Java it supports 7 other languages. Beside the simple follow/notify feature it can also directly monitor GitHub and BitBucket repositories and notify your about out-dated dependencies in your projects.

enter image description here

There is also a REST JSON API, for tool integrations.

By the way, I'm the dude who started this project. Let me know if you have questions.

Upvotes: 22

rd3n
rd3n

Reputation: 4560

If you want to receive email notifications when newer artifacts versions are available on Maven Central you can create an account on artifact-listener and choose which artifact you want to follow.
You can either search manually for artifacts or directly upload your pom.xml.

You will periodically received notifications like this one (available in english and french for now) :

Maven artifact listener

Upvotes: 38

jrh3k5
jrh3k5

Reputation: 31

You can use the Versions Maven Plugin[1] to generate reports in your Maven site to get a list of possible updates. With regard to Spring's irregularity, it appears to use the Mercury versioning system[2]. When configuring the Versions plugin, you can add a special rule for Spring stuff:

  1. http://mojo.codehaus.org/versions-maven-plugin/
  2. http://docs.codehaus.org/display/MAVEN/Mercury+Version+Ranges

Upvotes: 3

Related Questions