Over a million developers have joined DZone.

Maven 2 License Plugin: Easily Manage License Headers

DZone's Guide to

Maven 2 License Plugin: Easily Manage License Headers

· ·
Free Resource
When you are developing Java projects (using Maven 2) you can be faced to either put your whole project Open Source or just a part of it. But when the time comes to open source, you have some details to consider, one of it being the inclusion of a header license on your source files. Another issue you could have is changing the license you have on all your source files to another one, or just some elements of it, like data, owner, ...

All this required work is quite time expensive and a developer doesn't need to spend his or her time managing headers on source files.

Searching on the Internet, I found only these tools relative to license header:

But these tools lack features. Using Maven intensively as a project management tool, I wanted to have a Maven 2 plugin capable of checking in the verify phase if the license headers are here, and of course with the ability to add or update these headers.

Therefore I wrote a Maven 2 license plugin available at http://code.google.com/p/maven-license-plugin/ that anyone can use in his or her POM like this:


There are several other way of using it and a lot of configuration options all documented on the Google project website.

To invoke the plugin, simply issue:

mvn license:check
mvn license:format

These are the two goals available, the first one to check if header are present and the other one to reformat source files.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}