admin管理员组

文章数量:1648358


Apache License 2.0的使用限制有很多介绍,这篇文章说明一下在项目中使用Apache License 2.0的步骤和注意事项。

最常见的理解误区

在项目的根目录下,创建一个LISENCE文件,其内容为Apache官网提供的Apache Lisence 2.0的内容,就满足了Apache License 2.0的要求,这种不太准确的理解非常常见,而事实上并非如此,规范使用Apache License 2.0需要不少注意的事项。

实施细节

实施细节1:LICENSE文件

准备LICENSE文件,此文件内容请从Apache官方获取,目前URL如下所示:

  • http://www.apache/licenses/LICENSE-2.0.html

注意事项:

  • LICENSE文件名称请不要修改
  • LICENSE文件名称不需要后缀
  • LICENSE文件中保存官方内容部分请不要修改
  • LICENSE文件放置的路径一般需要在根目录下,同时根据需要一般在相应的各子模块根目录下也可以保存,尽可能不要藏的太深

实施细节2: NOTICE文件

准备NOTICE文件,此文件用于保存声明的信息,一般使用到的三方类库也会在此处提出。

注意事项:

  • NOTICE文件名称请不要修改
  • NOTICE文件名称不需要后缀
  • NOTICE文件放置的路径一般需要在根目录下,和LICENSE文件同一层级,尽可能不要藏的太深

实施细节3: 文件头级别的声明内容

其实Apache License 2.0的官方文档中已经有明确说明(附文的HOW TO APPLY THE APACHE LICENSE TO YOUR WORK部分),具体来说有如下的声明内容:

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/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.
  • 需要做的事情:替换Copyright [yyyy] [name of copyright owner]此行中中括号中的内容

注意事项:

  • yyyy使用四位的年份来替换,年份为发布代码的所在年份
  • name of copyright owner替换为本人或者组织的信息(License权利的拥有者/许可方:Licensor)
  • 中括号不要保留,请删除,不然会显得很傻,为此官方特意加了小括号提示,请不要浪费其良苦用心(Don’t include the brackets!),还有个!。
  • 此内容为文件级别的内容
  • 内容一般以注视的方式放在文件头部,需要注意不同文件格式的注释不同
  • 使用RCS、CVS或者SVN都有占位符可以通过扩展的方式展开此部分内容,但是一般不建议这么做,因为这种方式在源码搜索的时候占位符的内容尚未展开,所以可能搜素不出来。

示例文件

Apache顶级项目SkyWalking上个月和博云因为开源License的使用小吵了一架,仔细看了一下Apache SkyWalking的使用方式,确实非常规范,这里列出来作为大家的参考。

LICENSE

根目录下的LICENSE文件内容如下所示,请主要注意APPENDIX的部分:

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or

本文标签: 开源协议项目LicenseApache