Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check pom.xml for updated dependencies

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.

like image 708
Jesper Rønn-Jensen Avatar asked Aug 18 '10 20:08

Jesper Rønn-Jensen


People also ask

How do I know if POM xml is correct?

Just do an mvn clean on command line which will check the pom. xml and print out the information you need.

How do I mention the latest version of POM?

versions:use-latest-versions searches the pom for all versions which have been a newer version and replaces them with the latest version. 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.

How do you check the dependency tree in POM?

Eclipse pom. xml “Dependency Hierarchy” tab shows the dependency tree of the project. It has two sides - the left side shows verbose output and the right side shows the resolved dependencies. We can use the “Filter” option to look for a specific dependency.


1 Answers

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

  • versions:display-dependency-updates scans a project's dependencies and produces a report of those dependencies which have newer versions available.
  • versions:display-plugin-updates scans a project's plugins and produces a report of those plugins which have newer versions available.

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> 
like image 158
Pascal Thivent Avatar answered Oct 08 '22 06:10

Pascal Thivent