Automatically managing license/author/version header in source files

It is generally considered good practice to add some lines with author, version and license information to the top of source files.

That depends. First of all there are two (and more) ways to do this:

  • manage licensing information per file
  • manage licensing information in a central location

If you start a project from scratch, the per-file method is often easy to do while keeping things clear. As you write, over time it becomes more difficult to keep track of things. So more and more projects switch to the central location variant.

The file-by-file method has the benefit that the scope of a work is clear. Often you write the name of the application in the file-comment. If a single file is taken out for some reason, the information is still in there and the documentation chain is not broken.

With the central location method, the benefit is that this is normally supported by your version control software, for example GIT. Commits can be signed by the committing person, and author can be given. It's documented who has written which code automatically and that information is stored in a central location: the VCS.

Keep a COPYING file with your package where you provide the main information centrally. You can easily generate the list of authors via the VCS. And per each file you can create one header that just specifies which software and where to look into, just a bare outline:

/**
 * Flux Deluxe v3.2.0 - Vector Drawing Redefined
 *
 * Copyright 2010, 2012 by its authors. 
 * Some rights reserved. See COPYING, AUTHORS.
 */

If you release a new version in a new year it's a no-brainer to update all files.


Use the License Header Manager