62

I am fairly new to Maven and pom.xml. Is there a way I can find out which of my dependencies that are outdated, so that I can update version numbers in my pom.xml.

In other languages, for instance, Ruby has the command gem list outdated that gives me a list of dependencies (rubygems) I can update

I am using IntelliJ Idea if that can help.

Naman
  • 27,789
  • 26
  • 218
  • 353
Jesper Rønn-Jensen
  • 106,591
  • 44
  • 118
  • 155

3 Answers3

110

You can do this with the Versions Maven Plugin. Check the following goals:

Here is a sample output (taken from the examples):

Checking for new dependency updates

The display-dependency-updates goal will check all the dependencies used in your project and display a list of those dependencies with newer versions available.

Here are some examples of what this looks like:

svn checkout http://svn.codehaus.org/mojo/trunk/mojo/build-helper-maven-plugin build-helper-maven-plugin
cd build-helper-maven-plugin

Run

mvn versions:display-dependency-updates

Which produces the following output:

[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] ------------------------------------------------------------------------

Pom install

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>versions-maven-plugin</artifactId>
  <version>2.5</version>
</plugin>
SomeGuyOnAComputer
  • 5,414
  • 6
  • 40
  • 72
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • Thanks a lot. it really worked well for me. Very intuitive to use – Jesper Rønn-Jensen Aug 21 '10 at 11:38
  • 7
    Multi-module projects that "externalize" all versions to Maven properties in the parent POM (best practice IMO) would maybe be better off using `mvn -N versions:display-property-updates` in the parent module. – Marcel Stör Jul 24 '12 at 06:57
  • POM dependencies for this plugin provided below – 8bitjunkie Jan 17 '13 at 13:31
  • 4
    My project has a section with spring boot's "spring-boot-dependencies" artifact. As a consequence, the display-plugin-updates goal is showing tons of potential updates of artifacts that I don't even use (i.e. they don't show when I do mvn dependency:tree). Is that a way to ignore such dependencies? – L. Holanda Feb 21 '18 at 23:27
10

If you want to do it fast you can use www.versioneye.com site.

There you can define your project and upload project pom.xml, the site will also send you regular emails which notify you about new updates.

You can also mention which libraries do you want to check for update.

I don't know if it automatically fully sync with maven repo or not, but I always find its lib versions are update.

Update:

After 6 years the project switched off :(

So the mvn versions:display-dependency-updates seems to be the choice.

Alireza Fattahi
  • 42,517
  • 14
  • 123
  • 173
9

It isn't obvious what the POM dependency is for this.

For your convenience:

<dependency>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>versions-maven-plugin</artifactId>
    <version>2.1</version>
</dependency>

and the Repository:

<repository>
    <id>Codehaus Mojo</id>
    <name>Codehaus Mojo</name>
    <url>https://nexus.codehaus.org/content/repositories/releases/</url>
</repository>
8bitjunkie
  • 12,793
  • 9
  • 57
  • 70