Mathieu has posted 10 posts at DZone. View Full User Profile

Maven 2 License Plugin: Easily Manage License Headers

02.25.2008
| 7628 views |
  • submit to reddit
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:

<build>
<plugins>
<plugin>
<groupId>com.mathieucarbou.mojo</groupId>
<artifactId>maven-license-plugin</artifactId>
<configuration>
<headerFile>src/main/etc/header.txt</headerFile>
</configuration>
</plugin>
</plugins>
</build>

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.
0
Average: 4 (2 votes)
Published at DZone with permission of its author, Mathieu Carbou.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)