Discussions

News: Easily manage license headers of your source files with Maven

  1. Licensing source code can be rough, especially if you're changing licenses, or adding license references to code that's already been written or generated. Modifying licenses is quite time expensive and a developer doesn't necessarily want to spend his or her time managing headers on source files. Searching on the Internet, I found only these tools relative to license headers:
    • Release Audit Tool
    • The Maven 2 plugin for RAT
    • Checkstyle
    • Another one (which I do not remember the name) that is just a command-line tool [Editor's note: I tried to find a command-line tool for this, to no avail. Anyone who would like to offer pointers is welcomed to do so.]
    These tools lack features. Since I use Maven as a project management tool, I wanted to have a Maven 2 plugin capable of checking if the license headers are present, in the verify phase, and of course I wanted 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 a POM like this: com.mathieucarbou.mojo maven-license-plugin src/main/etc/header.txt 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:formatThese are the two goals available, the first one is to check if headers are present and the other one reformats the source files.

    Threaded Messages (9)

  2. Centrally-located Header File?[ Go to top ]

    Does "headerFile" currently support URIs? S, ALR
  3. For the moment it only support File objects. But i thougth to add support for URIs... It would be a nice feature to add, and not so complicated to implement. (URIs from classpath, http, ftp, ...) Feel free to add your requests to the issue management system at http://code.google.com/p/maven-license-plugin/issues/list
  4. I like it. I was looking for something like this just the other day. One issue though - I'm having trouble using it. Do you have a repository somewhere with it deployed, or failing that, do you have com.mathieucarbou:parent-pom 1.1.5 so I can build it?
  5. There is a How To on the website: http://code.google.com/p/maven-license-plugin/wiki/HowTo Basically, you need to add my repository location to your settings.xml or your pom to access the plugin, parent-pom and of course other project releases. I checked to see if i could upload or sync my repository in maven 2 central, but unfortunately i cannot use any rsync server to synchronize with central repo, and when you are using parent poms, you cannot create bundles and send them. All is explained at http://maven.apache.org/guides/mini/guide-central-repository-upload.html
  6. mojo.codehaus.org[ Go to top ]

    Have you considered moving it to mojo.codehaus.org? That has 2 advantages: - org.apache.maven.plugins and org.codehaus.mojo scoped plugins are automatically recognized as maven plugins. So "license:check" would work without having to configure the plugin in the pom.xml - People would find it easier, because mojo.codehaus.org is the place to look for all non-project specific maven plugins, such as this one.
  7. Re: mojo.codehaus.org[ Go to top ]

    Yes it would be great to move to mojo.codehaus.org. I added a request in the issue tracker to remind me to check for this ;)
  8. What's the future of Maven?[ Go to top ]

    This might be a fine plugin - but I've been reading some many complaints lately on Maven, of which this one was one that a attracted a lot attention, that I'm starting the wonder where Maven's future is heading. Why not ensure that Maven works 100% of the time, instead of the current 60%?
  9. Re: What's the future of Maven?[ Go to top ]

    There's an easy way to turn maven 2.0 from an unstable build (out-of-the-box) into a stable build: lock down your plugin versions.
    ... I'm starting the wonder where Maven's future is heading.
    The maven dev list is very active. They are looking into less verbose pom.xml's and forcing plugin version lock down (through plugin groups) in 2.1.
  10. Heh[ Go to top ]

    This might be a fine plugin - but I've been reading some many complaints lately on Maven, of which this one was one that a attracted a lot attention, that I'm starting the wonder where Maven's future is heading.

    Why not ensure that Maven works 100% of the time, instead of the current 60%?
    +1 This reminds me of the old joke : You have a problem - you need to manage license files. Then you think "I know ! I'll use Maven to do this !" Now you have two problems. :-)