项目开源准备-license和notice文件

近期接到个任务,组内有个项目计划开源,让我负责生成license和notice文件,看了网上别的开源项目的,最终采用org.codehaus.mojo.license-maven-plugin和org.jasig.maven.maven-notice-plugin这两个插件,pom配置如下:

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>2.0.0</version>
                <configuration>
                    <!-- update header -->
                    <inceptionYear>2019</inceptionYear>
                    <licenseName>apache_v2</licenseName>
                    <organizationName>${organizationName}</organizationName>
                    <projectName>${projectName}</projectName>
                    <processStartTag>&nbsp;</processStartTag>
                    <processEndTag>&nbsp;</processEndTag>
                    <sectionDelimiter>&nbsp;</sectionDelimiter>
                    <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
                    <emptyLineAfterHeader>true</emptyLineAfterHeader>
                    <outputDirectory>${project.basedir}</outputDirectory>
                    <useMissingFile>true</useMissingFile>
                    <thirdPartyFilename>LICENSE-3RD-PARTY</thirdPartyFilename>
                    <executeOnlyOnRootModule>true</executeOnlyOnRootModule>
                    <missingFile>${project.basedir}/LICENSE-3RD-PART.propertie</missingFile>
                    <roots>
                        <root>src/main/java</root>
                        <root>src/test/java</root>
                    </roots>
                    <includes>
                        <include>**/*.java</include>
                        <include>**/*.xml</include>
                        <include>**/*.sh</include>
                        <include>**/*.properties</include>
                        <include>**/*.sql</include>
                        <include>**/*.html</include>
                        <include>**/*.less</include>
                        <include>**/*.css</include>
                        <include>**/*.js</include>
                        <include>**/*.json</include>
                    </includes>

                    <!-- license:aggregate-download-licenses -->
                    <licensesOutputFile>${project.basedir}/lic/licenses.xml</licensesOutputFile>
                    <licensesOutputDirectory>${project.basedir}/lic/licenses/</licensesOutputDirectory>
                    <licensesErrorsFile>${project.basedir}/lic/licenses-errors.xml</licensesErrorsFile>

                    <!-- config for mvn license:update-project-license -->
                    <licenseFile>${project.basedir}/LICENSE</licenseFile>

                    <licenseMerges>
                        <licenseMerge>Apache 2.0|ASL, version
                            2|http://www.apache.org/licenses/LICENSE-2.0.txt|http://asm.ow2.org/license.html|The
                            Apache License, Version 2.0|Apache License|Apache License Version 2|Apache License
                            Version 2.0|Apache Software License - Version 2.0|Apache 2.0 License|Apache License
                            2.0|ASL|Apache 2|Apache-2.0|the Apache License, ASL Version 2.0|The Apache Software
                            License, Version 2.0|Apache License, Version 2.0|Apache Public License 2.0
                        </licenseMerge>
                        <licenseMerge>BSD|The BSD 3-Clause License|The BSD License|Modified BSD License|New BSD
                            License|New BSD license|Two-clause BSD-style license|BSD licence|BSD New|The New BSD
                            License|BSD 3-Clause|BSD 3-clause
                        </licenseMerge>
                        <licenseMerge>MIT|MIT License|The MIT License</licenseMerge>
                        <licenseMerge>LGPL|LGPL, version 2.1|GNU Library or Lesser General Public License (LGPL)
                            V2.1|GNU Lesser General Public License (LGPL), Version 2.1|GNU Lesser General Public
                            License, Version 2.1|LGPL 2.1
                        </licenseMerge>
                        <licenseMerge>CDDL|CDDL+GPL|CDDL+GPL License|CDDL + GPLv2 with classpath exception|CDDL
                            License|CDDL 1.0|CDDL 1.1|COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version
                            1.0|Common Development and Distribution License (CDDL) v1.0
                        </licenseMerge>
                        <licenseMerge>EPL|Eclipse Public License - Version 1.0</licenseMerge>
                        <licenseMerge>GPL|GPL2 w/ CPE|GPLv2+CE|GNU General Public Library</licenseMerge>
                        <licenseMerge>MPL|MPL 1.1</licenseMerge>
                        <licenseMerge>Public Domain</licenseMerge>
                        <licenseMerge>Common Public License|Common Public License Version 1.0</licenseMerge>
                        <licenseMerge>CC0|CC0 1.0 Universal|Public Domain, per Creative Commons CC0</licenseMerge>
                        <licenseMerge>Unknown License|Unknown license</licenseMerge>
                    </licenseMerges>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jasig.maven</groupId>
                <artifactId>maven-notice-plugin</artifactId>
                <version>1.1.0</version>
                <configuration>
                    <generateChildNotices>false</generateChildNotices>
                    <noticeTemplate>https://source.jasig.org/licenses/NOTICE.template</noticeTemplate>
                    <licenseMapping>
                        <param>${project.basedir}/lic/license-mappings.xml</param>
                        <param>https://source.jasig.org/licenses/license-mappings.xml</param>
                    </licenseMapping>
                </configuration>
            </plugin>

需要将上述内容中的${organizationName}和${projectName}替换成你的真实组织和项目名字。

生成notice文件的时候由于部分jar包在maven仓库中没有,项目内是通过system引入的,需要单独配置下这些找不到license依赖的license,例如我的license-mappings.xml配置文件:

<license-lookup xmlns="https://source.jasig.org/schemas/maven-notice-plugin/license-lookup"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://source.jasig.org/schemas/maven-notice-plugin/license-lookup https://source.jasig.org/schemas/maven-notice-plugin/license-lookup/license-lookup-v1.0.xsd">

    <artifact>
        <groupId>org.codehaus.jettison</groupId>
        <artifactId>jettison</artifactId>
        <license>Apache License, Version 2.0</license>
    </artifact>
    <artifact>
        <groupId>org.apache.zookeeper</groupId>
        <artifactId>zookeeper</artifactId>
        <license>Apache License, Version 2.0</license>
    </artifact>
    <artifact>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-auth</artifactId>
        <license>Apache License, Version 2.0</license>
    </artifact>
    <artifact>
        <groupId>com.robert.vesta</groupId>
        <artifactId>vesta-service</artifactId>
        <license>Apache License, Version 2.0</license>
    </artifact>
    <artifact>
        <groupId>com.robert.vesta</groupId>
        <artifactId>vesta-intf</artifactId>
        <license>Apache License, Version 2.0</license>
    </artifact>
</license-lookup>

之后通过下列命令即可将对应的license/notice以及代码中的文件头注释一起生成

mvn license:update-file-header
mvn license:aggregate-add-third-party
mvn license:update-project-license
mvn license:aggregate-download-licenses
mvn notice:generate

最终效果就是下述图片所示:

CREATE TABLE `boshi_personalcenter` ( `PersonalCenterId` int(11) NOT NULL COMMENT '(id)', `PersonalCenterIntegral` int(11) DEFAULT NULL COMMENT '(个人积分)', `PersonalCenterSZ` varchar(300) DEFAULT NULL COMMENT '(身份证正面)', `PersonalCenterSF` varchar(300) DEFAULT NULL COMMENT '(身份证反面)', `PersonalCenterXZ` varchar(300) DEFAULT NULL COMMENT '(学生证正面)', `PersonalCenterXF` varchar(300) DEFAULT NULL COMMENT '(学生证反面)', `PersonalCenterCredit` int(11) DEFAULT NULL COMMENT '(信用度)', KEY `PersonalCenterId` (`PersonalCenterId`), CONSTRAINT `boshi_personalcenter_ibfk_2` FOREIGN KEY (`PersonalCenterId`) REFERENCES `user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*Data for the table `boshi_personalcenter` */ insert into `boshi_personalcenter`(`PersonalCenterId`,`PersonalCenterIntegral`,`PersonalCenterSZ`,`PersonalCenterSF`,`PersonalCenterXZ`,`PersonalCenterXF`,`PersonalCenterCredit`) values (1,10,'tu','tu','tu','tu',100),(2,20,'tu','tu','tu','tu',100),(3,30,'tu','tu','tu','tu',100),(1,50,'身份证正面','身份证反面','学生证正面','学生证反面',10),(1,50,'身份证正面','身份证反面','学生证正面','学生证反面',10),(1,50,'身份证正面','身份证反面','学生证正面','学生证反面',10); /*Table structure for table `boshi_profile` */ DROP TABLE IF EXISTS `boshi_profile`; CREATE TABLE `boshi_profile` ( `ProfilePeoId` int(11) DEFAULT NULL COMMENT '(用户ID信息) 外键', `ProfileName` varchar(300) DEFAULT NULL COMMENT '(姓名)', `ProfilePhp` varchar(300) DEFAULT NULL COMMENT '(联系方式)', `ProfileAddress` varchar(300) DEFAULT NULL COMMENT '(地址)', `ProfileId` int(11) NOT NULL AUTO_INCREMENT COMMENT '(地址id)', PRIMARY KEY (`ProfileId`), KEY `ProfilePeoId` (`ProfilePeoId`), CONSTRAINT `boshi_profile_ibfk_1` FOREIGN KEY (`ProfilePeoId`) REFERENCES `user` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8; /*Data for the table `boshi_profile` */ insert into `boshi_profile`(`ProfilePeoId`,`ProfileName`,`ProfilePhp`,`ProfileAddress`,`ProfileId`) values (2,'赵六','1366663435','合肥',2),(2,'斩三','13214326346','合肥',5),(2,'李四','12334453654','北大青鸟',6),(2,'李四','1888555555','包河区',7),(2,'赵六','1366663435','合肥',8),(2,'赵六','12354697883','上海市',9),(2,'赵六','12354697883','上海市',10),(2,'赵六','12354697883','上海市',11),(1,'张三','17776462665','合肥市包河区',12),(1,'王五','1423534534654','合肥市',13),(2,'赵六','1366663435','合肥',14),(1,'赵六','17776462665','北大青鸟',20); /*Table structure for table `boshi_putaway` */ DROP TABLE IF EXISTS `boshi_putaway`;
NCSA许可证是一种开源软件许可证,它是由美国国家计算科学应用研究所(NCSA)创建的。该许可证允许用户自由地使用、修改和分发软件,但要求在软件的副本中包含版权声明和许可证条款。此外,NCSA许可证还要求在使用软件的研究论文或出版物中引用原始软件的来源。 以下是NCSA许可证的一个示例: ```text Software License Agreement (NCSA) Version 1.0 1. This Agreement ("Agreement") is made and entered into by and between the University of Illinois Board of Trustees ("Licensor") and the party ("Licensee") who has agreed to the terms of this Agreement. 2. Licensor hereby grants Licensee a non-exclusive, royalty-free, perpetual, worldwide license to use, copy, modify, and distribute this software and its documentation, without fee, provided that this license agreement and copyright notice appear in all copies of the software and its documentation, and that Licensee does not sell the software. 3. Licensee may distribute the software and its documentation in object code form only, provided that: (a) Licensee ensures that any distribution of the software and its documentation by Licensee includes a verbatim copy of this Agreement, and (b) Licensee ensures that any distribution of the software and its documentation by Licensee includes the original source code and source code comments, if any, for the software. 4. Licensee may make derivative works of the software and distribute such derivative works, provided that: (a) Licensee ensures that any distribution of derivative works of the software by Licensee includes a verbatim copy of this Agreement, and (b) Licensee ensures that any distribution of derivative works of the software by Licensee includes the original source code and source code comments, if any, for the software. 5. Licensee agrees that any public display, public performance, sale, lease, rental, distribution, or other transfer of the software and its documentation by Licensee shall be in compliance with all applicable laws, including but not limited to copyright laws. 6. Licensee agrees that Licensor has no duty of support or maintenance of any kind with respect to the software and its documentation. 7. THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH LICENSEE. SHOULD THE SOFTWARE PROVE DEFECTIVE, LICENSEE ASSUMES THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 8. IN NO EVENT SHALL LICENSOR BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS OF PROFITS, OR FOR ANY CLAIMS OR DEMANDS AGAINST LICENSEE BY ANY OTHER PARTY, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE ABOVE EXCLUSION MAY NOT APPLY TO LICENSEE. 9. This Agreement shall be construed and governed by the laws of the State of Illinois, without regard to its conflicts of law provisions. 10. This Agreement constitutes the entire agreement between the parties with respect to the subject matter hereof and supersedes all prior oral or written agreements, understandings or representations between the parties relating to the subject matter hereof. Any modifications to this Agreement must be in writing and signed by both parties. ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值