Wednesday, November 18, 2009

How to Apply the Apache 2.0 License to Your Project

Every once is a while I get asked the questions about open source licenses.  Here is a simple tutorial on how to apply the Apache 2.0 License to your project.

1. First you'll need a copy of the Apache 2.0 License for your project. Grab a copy by downloading in text form from the Apache Software Foundation.
2. Now, you need to modify a notice statement so you can add them to your files. We'll get to where you put the notice statement in step 3 so just hold your horses for a moment. Here is boilerplate notice which you will modify for your project:

   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.


Some things you must do:

a) Replace all [bracketed] items in the above notice statement. There are only two of these items so should not be hard for you to do.
b) Do not leave the brackets in the notice. For example, "[yyyy]" would be replaced with "2009" (or what ever year you release in). Again, do not leave the brackets in the notice statement.

3. Apply the your notice statement to each and every file in which the Apache License applies. The most common mistake when applying the license that people think that supplying the license text is enough to make your the project licensed under the Apache License.  Again, you must place a copy of the notice statement (probably at the top) in the appropriate "comment syntax" for the file format.

4. Secondly, you need two files in the root or top directory of your distribution.  It's best to not deeply nest them in a some directory deep in your project.  Leave them in the root or top directory. One file should be named LICENSE (no file extension) in which you will place the text from the license you just downloaded in step 1. The other file that is required is a file named NOTICE in which you place a copy of your notice statement you modified above and a listing of the names of licensed libraries used in your project (be sure to list the names of the developers of those projects as well -- show your appreciation).

5. If use other code in your project that is licensed under a different license, I must make sure those libraries are compatible with the Apache 2.0 License.  For example, GPL version 2.0 is not compatible with the Apache 2.0 license. Also, you must leave any original copyright and patent notices in the code you redistribute.  It is important that you preserve this notifications and you must explicitly sate if you made changes to that file.

Presto! You're done!  The depending on the size of the project, adding the notice statement to each file will take you the most time.  I'd recommend against using a SVN keyword or other placeholder to dynamically insert the notice statement at build time because your notice would not be present when browsing code through a source code repository (such as SVN or CVS).

No comments:

Post a Comment