I am a big fan of static analysis and formatting tools. I just like my code to be as clean as possible. At the very least, being clean makes the code easier to read and maintain. If I can find a tool that will make it easy for me to keep my code clean, I’ll use it.

Recently I found the Maven POM Lint plugin. It runs against your pom.xml file and applies a series of rules that amount to best practices on ordering, including optional fields, and eliminating duplication. It provides a way to keep your pom.xml file clean without much additional effort.

In the <build> section of our pom.xml file, we add:


The plugin provides two goals. The first is lint:list. It shows a list of the rules that the plugin will run against the pom.xml file. A short description for each rule is shown, but some of the descriptions are incomplete and don’t give much more information than the error message does. Still, being able to see the list of the rules that will be applied can be useful.

The more important goal is lint:check. It applies the rules and reports on any violations it finds. By default, the build will fail if there are any violations found. Any violations that are found are reported to the console and written out to an XML file (by default,  target/maven-lint-result.xml).

[INFO] ------------------------------------------------------------------------
[INFO] Building SampleMavenApp 0.0.3-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] --- lint-maven-plugin:0.0.8:check (default-cli) @ sample-maven ---
[INFO] Writing summary report
[INFO] [LINT] Completed with 3 violations
[INFO] [LINT] OSSDevelopersSectionRule: missing <developers/> section : 0:0 : C:\Users\Gene Gotimer\workspace\hangman\pom.xml
[INFO] [LINT] OSSInceptionYearRule: missing <inceptionYear/> information : 0:0 : C:\Users\Gene Gotimer\workspace\hangman\pom.xml
[INFO] [LINT] GAVOrder: Found 'name' but was expecting 'packaging' : 19:8 : C:\Users\Gene Gotimer\workspace\hangman\pom.xml
[INFO] Writing xml report
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------

The list of rules to apply can be explicitly defined if you some of them do not apply to your project.

It may not add much to your project, but it doesn’t take much to run and keep your POM file a little cleaner.

Leave a comment

Your email address will not be published. Required fields are marked *