Skip to main content

About the Apache license header

Posted by fabriziogiudici on November 16, 2010 at 4:26 AM PST

While we're more or less all well-informed people, if you dare to read general comments related to the Oracle-Google affair, not only by casual readers, but also by supposed-to-be-professionals writing in generic newspapers and news sites you'll find lots of wrong or at least badly written assertions. One of the most recurring misconceptions is the use of the Apache license header, as it has been pointed out by Apache in an official blog post and by Stephen Couleborne in many comments in the blogosphere (the latest one here). Indeed the problem seems to be that the Apache license header has been naively copied by somebody who committed to Android (as I said before, there's also the problem in the package name of the infamous class, that seemed to refer to Harmony).
Ok, big fault at Google. But, what about us? Are we applying the correct license headers to our code? Are we checking them?

For instance, if you download the original Apache License you can read at the bottom:

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Note that this is a very simple but complete how-to and explains that you should add a specific Copyright notice with your name / reference. Paraphrasing Cay, you shouldn't just "slap the Apache license header" to your files. For instance, this is my standard header:

/***********************************************************************************************************************
 *
 * blueBill Mobile - open source birdwatching
 * ==========================================
 *
 * Copyright (C) 2009, 2010 by Tidalwave s.a.s. (http://www.tidalwave.it)
 * http://bluebill.tidalwave.it/mobile/
 *
 ***********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 ***********************************************************************************************************************
 *
 * $Id: ControlFlow.java,v 67dcb737b74e 2010/06/09 01:20:14 fabrizio $
 *
 **********************************************************************************************************************/

Note that nobody would have any doubt that this code is mine and not by the Apache Software Foundation. Is this a correct way to write a license header?

Are you handling your headers with the needed care? There are even Ant and Maven based tools to perform an automatic check that every file is properly equipped with a header (of course, it's up to you to define it); as far as I know, at least some of the official Apache projects include this check in the automated tests (something that we should all do... it's easy).

Related Topics >>

Comments

About the Apache license

I license my files under different conditions to different partners. That's why I avoid including license terms in the file header.
I only state that the file may not be used if not licensed, and that details are given in a separate file.
This keeps the file header short and crisp. :-)

About the Apache license

Thanks Stephen. It's a sort of a waste, because I don't think my code will be ever so interesting to be part of a lawsuit. but it doesn't cost much to put all the info there.
Yes, Lucio, I know that Maven plugin even though I've been lazy and never used so far.

I'm pretty sure you already

I'm pretty sure you already know, but the Maven tool (the license plugin) can also update your files for including the licence header. Maybe also the ant tool, I don't know.

About the Apache license

Your header certainly looks like it meets and exceeds the license application advice. Its certainly more thorough than I use in Joda!