Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I easily diff dependencies between two Maven pom files?

Tags:

maven

pom.xml

My boss likes for the dependencies in a given Maven pom file to be sorted by scope, group, and artifact ID.

I've recently inherited a fair number of projects with a fair number of dependencies that were not sorted. So I sorted them.

Long story short, I want to make sure I did not inadvertently drop a dependency or copied in the wrong sorted dependency into the wrong pom.

So I was wondering if there was some sort of mechanism or Maven report plugin that will diff a pom with a previous version and show me what dependencies were added or modified.

Does anything like this exist?

like image 850
Jason Thompson Avatar asked Mar 29 '13 19:03

Jason Thompson


1 Answers

I like to use a simple script to get a sorted list of dependencies and then compare them with a difftool like meld.

#!/bin/bash
# first grab all dependencies
mvn dependency:resolve >/dev/null

# then list them with -o to keep noise low,
# remove extra information and duplicates
mvn -o dependency:list \
| grep ":.*:.*:.*" \
| cut -d] -f2- \
| sed 's/:[a-z]*$//g' \
| sort -u 
like image 194
Marc Johnen Avatar answered Sep 25 '22 10:09

Marc Johnen