Thibaud Ledent

Home

Sort Maven pom.xml files

Published Jan 27, 2022

I already had an article to sort json files. This time, I’m tackling maven pom.xml files!

Indeed, it is sometimes interesting to compare plugins and dependencies of two projects (e.g. to see if all plugins are present in a new project, if all configuration are there…). Comparing the pom.xml of the projects is one option, and it’s easier to do when the pom’s are sorted.

To sort a pom.xml, I found a small maven plugin:

mvn com.github.ekryd.sortpom:sortpom-maven-plugin:sort \
    -Dsort.keepBlankLines \
    -Dsort.predefinedSortOrder=custom_1 \
    -Dsort.nrOfIndentSpace=4 \
    -Dsort.createBackupFile=false

References