667481 members! Sign up to stay informed.

Sponsored Links


Resources

Enterprise Java
Research Library

Get Java white papers, product information, case studies and webcasts

News News News Messages: 9 Messages: 9 Messages: 9 Printer friendly Printer friendly Printer friendly Post reply Post reply Post reply XML XML XML

Easily manage license headers of your source files with Maven

Posted by: Mathieu Carbou on February 26, 2008 DIGG
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:
<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 is to check if headers are present and the other one reformats the source files.

Threaded replies

·  Easily manage license headers of your source files with Maven by Mathieu Carbou on Tue Feb 26 10:22:24 EST 2008
  ·  Centrally-located Header File? by Andrew Rubinger on Tue Feb 26 13:55:55 EST 2008
    ·  Re: Does "headerFile" currently support URIs? by Mathieu Carbou on Tue Feb 26 18:27:02 EST 2008
  ·  Re: Easily manage license headers of your source files with Mave by Jared Bunting on Tue Feb 26 15:23:01 EST 2008
    ·  Re: Re: Easily manage license headers of your source files with by Mathieu Carbou on Tue Feb 26 18:34:06 EST 2008
  ·  mojo.codehaus.org by Geoffrey De Smet on Wed Feb 27 02:46:40 EST 2008
    ·  Re: mojo.codehaus.org by Mathieu Carbou on Wed Feb 27 08:53:44 EST 2008
  ·  What's the future of Maven? by Jan Vissers on Wed Feb 27 03:37:31 EST 2008
    ·  Re: What's the future of Maven? by Geoffrey De Smet on Wed Feb 27 14:15:31 EST 2008
    ·  Heh by Ethan Allen on Thu Feb 28 18:17:06 EST 2008
  Message #247991 Post reply Post reply Post reply Go to top Go to top Go to top

Centrally-located Header File?

Posted by: Andrew Rubinger on February 26, 2008 in response to Message #247928
Does "headerFile" currently support URIs?

S,
ALR

  Message #248001 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Easily manage license headers of your source files with Mave

Posted by: Jared Bunting on February 26, 2008 in response to Message #247928
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?

  Message #248007 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Does "headerFile" currently support URIs?

Posted by: Mathieu Carbou on February 26, 2008 in response to Message #247991
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

  Message #248009 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Re: Easily manage license headers of your source files with

Posted by: Mathieu Carbou on February 26, 2008 in response to Message #248001
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

  Message #248025 Post reply Post reply Post reply Go to top Go to top Go to top

mojo.codehaus.org

Posted by: Geoffrey De Smet on February 27, 2008 in response to Message #247928
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.

  Message #248026 Post reply Post reply Post reply Go to top Go to top Go to top

What's the future of Maven?

Posted by: Jan Vissers on February 27, 2008 in response to Message #247928
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%?

  Message #248039 Post reply Post reply Post reply Go to top Go to top Go to top

Re: mojo.codehaus.org

Posted by: Mathieu Carbou on February 27, 2008 in response to Message #248025
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 ;)

  Message #248086 Post reply Post reply Post reply Go to top Go to top Go to top

Re: What's the future of Maven?

Posted by: Geoffrey De Smet on February 27, 2008 in response to Message #248026
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.

  Message #248188 Post reply Post reply Post reply Go to top Go to top Go to top

Heh

Posted by: Ethan Allen on February 28, 2008 in response to Message #248026
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.

:-)

New content on TheServerSide.comNew content on TheServerSide.comNew content on TheServerSide.com

Dependency Injection in Java EE 6 - Part 1

Reza Rahman explores the features of the proposed JSR 299, Contexts and Dependency Injection for Java EE (CDI). When approved, it promises to be a key feature of Java EE 6. (November 2, Article)

SAML: It's Not just for Web services

SAML is an XML-based standard for exchanging authentication and authorization data between security domains. The single most important problem that SAML was created to solve is the Web browser Single Sign-On problem. Many organizations are debating whether to stay with version 1.1 or move to 2.0. This article makes observations about both options. (September 28, Article)

Programming is Also Teaching Your Team

Joe Ottinger takes a look at how people learn, and applies it to the practice of programming. He notes that understanding how people learn is an essential part of working in a programming team. (September 22, Article)

Can Java EE Deliver The Asynchronous Web?

Stephen Maryka gave us an article about the Asynchronous Web and posed a number of questions that get examined like an approach to delivering Asynchronous Web capabilities through extensions to existing Java EE technologies. (July 14, Article)

JSF Flex

JavaServer Faces Flex goal is to provide users capability in creating standard Flex components, part of flexSDK which is open sourced through MPL license, as normal JSF components. This article by Ji Hoon Kim will provide an overview of creating a simple multilingual JSF page consisting of JSF Flex tags. (June 29, Article)

The Rules of SOA - A Road to a Successful SOA Implementation

In this session Jeff explores the key characteristics of successful SOA projects. He covers some of the patterns, and anti-patterns, tool sets, and strategies that he himself learned the hard way. Last, he provides a strategy and blueprint for achieving a high likelihood of success in your SOA project. (June 23, Tech Talk)

Ari Zilka Talks About Terracotta 3.1

Ari Zilka, CTO of Terracotta, Inc., talks about the new features in Terracotta 3.1, announced during JavaOne and available now. (June 15, Tech Talk)

Enterprise Application Integration, and Spring

In this Tech Talk, Josh Long explores an integration challenge using Spring Integration and walks through the implementation, employing and expanding on the basic patterns of Enterprise Application Integration to tie together components into a function integration solution, and then demonstrates how Spring Integration helps address the integration requirements. (June 15, Tech Talk)

Google Web Toolkit: An Introduction

In this Tech Talk, David Geary teaches you: The basics of Google Web Toolkit; How to implement Ajax-enabled applications in Java; Internationalization; Hooking into the browser history mechanism; Remote procedure calls. (June 4, Tech Talk)

Just Enough Early Architecture to Guide Development

Jon Kern discusses the best architecture/technical solutions and ensure that they are repeated by all developers. By tackling the architecture up-front in a serial manner, subsequent parallel development will be much more manageable and predictable. (May 28, Tech Talk)

Productive Programmer: On the Lam from the Furniture Police

This keynote describes the frustrations of modern knowledge workers in their quest to actually get some work done, and solutions for how to guard yourself against all those distractions. Neal Ford talks about environments, coding, acceleration, automation, and avoiding repetition as ways to defeat the misguided attempts to sap your ability to produce good work. (May 26, Tech Talk)

Auto-Scaling Your Existing Web Application

Gil demonstrates how new, aggressive uses of already abundant compute capacity by common applications offer competitive value for application designers. (May 21, Tech Talk)

Automating Hibernate Mapping and Queries For Java Web Development

Chris Keene introduces WaveMaker as a new way to automate the ability to generate Hibernate classes in order to more quickly bring OR mapping into an application. (May 19, Article)

Auto-Scaling Your Existing Web Application

In this session Nati Shalom demonstrates how to take a standard Java EE web application and scale it out or down dynamically without changes to the application code. Seeing as most web applications are over-provisioned to meet infrequent peak loads, this is a dramatic change because it enables growing your application as needed, when needed, without paying for unutilized resources. (May 19, Tech Talk)

Free Book PDF Download: Mastering EJB Third Edition

Mastering EJB was one of the original and most influential EJB books in the industry. Mastering EJB III now returns with two new expert co-authors, updated for EJB 2.1 and 30% new chapters including security, integration, best practices, open source, and more.
(Book PDF Download)

Application Server Matrix

The Application Server Matrix is a detailed listing of J2EE vendors and their application server products, with information on latest version numbers, J2EE spec support and licensing, pricing, platform support, and links to product downloads and reviews.
(Application Server Comparison Matrix)

News | Blogs | Discussions | Tech talks | Patterns | Reviews | White Papers | Downloads | Articles | Media kit | About
Java Solutions
All Content Copyright ©2007 TheServerSide Privacy Policy
Site Map