如何使用Maven许可插件收集版权声明?

时间:2015-09-16 10:38:30

标签: maven licensing

我在项目中使用了许多开源库,并使用license-maven-plugin来收集有关它们的信息。我可以看到目标目录中的所有许可文本和THIRD-PARTY-included-modules.txt,如下所示:

Lists of 144 third-party dependencies.
 (Apache License 2.0) Commons Codec (commons-codec:commons-codec:1.8 - http://commons.apache.org/proper/commons-codec/)
 (Apache License 2.0) Commons IO (commons-io:commons-io:1.4 - http://commons.apache.org/io/)
 (Apache License 2.0) Commons Logging (commons-logging:commons-logging:1.1.3 - http://commons.apache.org/proper/commons-logging/)
 (CDDL) JavaBeans Activation Framework (JAF) (javax.activation:activation:1.0.2 - http://java.sun.com/products/javabeans/jaf/index.jsp)
...(and 140 more lines)

但是,这似乎与法律义务相符:

  

(来自MIT许可证)上述版权声明和本许可声明应包含在本软件的所有副本或实质部分中。

据我所知,我应该包含以下通知:

  

版权所有(C)2011,2014,2015 Tatsuhiro Tsujikawa

我应如何收集我应该在“关于”页面中包含的版权声明?

这是我的pom.xml:

<project ...>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>1.8</version>
                <configuration>
                    <!--
                        mvn clean license:add-third-party license:download-licenses
                    -->
                    <projectName>Play SQL PageObjects</projectName>
                    <licenseName>Commercial License</licenseName>
                    <organizationName>Play SQL S.A.S.U.</organizationName>
                    <inceptionYear>2015</inceptionYear>

                    <!-- Files we input into license-maven-plugin -->
                    <licenseFile>${basedir}/src/license/PLAY_SQL_LICENSE.txt</licenseFile>
                    <useMissingFile>true</useMissingFile>
                    <!-- The input file with the list of licenses, for those which can't be found automatically -->
                    <missingFile>src/license/THIRD-PARTY.properties</missingFile>
                    <!-- Same as 'missingFile' but in XML, probably -->
                    <licensesConfigFile>src/license/licenses-manual.xml</licensesConfigFile>

                    <!-- Output folder -->
                    <outputDirectory>${project.basedir}/target/classes/META-INF/licenses</outputDirectory>
                    <!-- Text with the output list of all licenses. Just contains the list of projects and websites, does not contain the copyright notices -->
                    <thirdPartyFilename>THIRD-PARTY-included-modules.txt</thirdPartyFilename>
                    <!-- XML with the output list of all licenses -->
                    <licensesOutputFile>target/classes/META-INF/licenses/licenses-generated.xml</licensesOutputFile>
                    <!-- Folder with an output dump of all license text. Usually they contain the license template (for APL2) but not the copyright notices. -->
                    <licensesOutputDirectory>target/classes/META-INF/licenses/text</licensesOutputDirectory>


                    <includedScopes>compile</includedScopes>
                    <excludedScopes>test|provided|runtime|system</excludedScopes>
                    <excludedGroups>com.playsql</excludedGroups>
                    <licenseMerges>
                        <licenseMerge>Apache License 2.0|The Apache Software License|Version 2.0,Apache License, Version 2.0|The Apache Software License, Version 2.0|Apache License, Version 2.0|Apache 2</licenseMerge>
                    </licenseMerges>
                </configuration>
            </plugin>

我如何使用license-maven-plugin(或任何其他工具)收集版权声明?

3 个答案:

答案 0 :(得分:1)

我不知道任何有效的版权扫描仪/收藏家可用作Maven插件。但您可以使用ScanCode工具包收集版权:它是为此目的和其他相关目的而设计的。 (免责声明:我是那里的开发者之一)

这只需要一个Python 2.7解释器,一旦安装,运行./scancode -c以获得JSON格式的版权。

在Maven插件中包装扫描码应该相当容易。需要帮助!

请参阅https://github.com/nexB/scancode-toolkit

答案 1 :(得分:1)

我已将attribution maven plugin用于此目的。它生成一个XML文件,其中包含同一POM中依赖项的所有已知许可证数据。然后,您可以将此XML文件包含在打包的代码中,并使用它来显示&#34; about&#34;页。

答案 2 :(得分:0)

我创建了mojohaus maven许可插件的分支。在这里讨论: https://github.com/mojohaus/license-maven-plugin/issues/357。 未经严格测试,很可能还剩下一些小错误,但就我的目的而言,它仍然有效。但是要警告! 专业说法:与ScanCode相比,该解决方案超级快,后者可以扫描暴力破解甚至二进制文件,并且还需要在扫描前提取所有 档案。

该插件将其可以提取的所有内容(包括许可证和声明文本文件)写入target\generated-resources\licenses.xml

声明文本文件通常包含您需要的版权声明。版权声明是编写扩展名的主要原因之一。

只需从https://github.com/JD-CSTx/license-maven-plugin中克隆它即可。 要快速构建并安装它以进行测试,请使用mvn install -DskipITs=true -DskipTests=true

目标是license:aggregate-download-licenses,版本是2.1.0-SNAPSHOT,选项是extendedInfo

它也可以使用选项writeExcelFile写入excel文件,请注意:由于32,767个字符的限制,Excel单元格被切断了。

为项目pom.xml配置:

<plugin>
  <groupId>org.codehaus.mojo</groupId>                   
  <artifactId>license-maven-plugin</artifactId>
    <version>2.1.0-SNAPSHOT</version>
    <configuration>
       <includeTransitiveDependencies>true</includeTransitiveDependencies>                       
       <verbose>true</verbose>
       <!-- New -->
       <extendedInfo>true</extendedInfo>
       <!-- New -->
       <writeExcelFile>true</writeExcelFile>
       ...

我希望对此有一些反馈。