# Third Party Copyright Guide
This document focus on the copyright of third party source code or binary packages involved in the development process.
# Source Code Reference
If the following situation exists in the code, it is considered as a reference to third party source code:
- Copy Overall: Copy files directly from third party source code and make changes based on them.
- Partial Copy: Copy some methods or inner classes in third party source code and use them in the self-developed code.
- Reference Design: If developers refer to the architecture of a third party when designing the architecture, and there is the same content in the two architectures, it is also considered as reference.
In all three cases, developers are required to complete the following work with the files involved:
- Add instructions for copying third party source code to your
LICENSEfile, like this:Note:The following files contain a portion of ${THIRD PARTY PROJECT NAME} project. ${RELATED FILE A} in this product is copied from ${THIRD PARTY FILE A} of ${THIRD PARTY PROJECT NAME} project. ${RELATED FILE B} in this product is copied from ${THIRD PARTY FILE B} of ${THIRD PARTY PROJECT NAME} project. ... ${THIRD PARTY PROJECT NAME} project is published at ${THIRD PARTY PROJECT CODEBASES URL} and its license is ${THIRD PARTY PROJECT LICENSE NAME}.THIRD PARTY PROJECT NAMErepresents the name of the third party project.RELATED FILEis the related file for this project: if it is a class, type the path of full qualified class name; Otherwise, type the project relative path.THIRD PARTY FILErepresents the copied file of the third party: if it is a class, type the path of full qualified class name; Otherwise, type the project relative path. If the third party project is a single module project, you can also type the relative path to the source directory.THIRD PARTY PROJECT CODEBASES URLrepresents the address of the third party project repository; If you can't find the address of source code, you can change it to the official website address or source code download address. In short, the principle is to be traceable.THIRD PARTY PROJECT LICENSE NAMErepresents to theLICENSEname of the third party project, which is usually referred to thelicenseslabel in thepomfile, or pluralized if multipleLICENSEexist:... and its licenses are ${LICENSE A}, ${LICENSE B}, ..., and ${LICENSE C}.If there is already an entry for the target third party project, just cut back and fill in the copy information in the middle.
- Type the header of the copied file (if exists) in the file in question and add the copy source information, like this:
Based on ${THIRD PARTY FILE} from the ${THIRD PARTY PROJECT NAME} project. - If a third party project contains a
NOTICEfile, append it to the end of theNOTICEfile of current project. If it is already included, there is no need to append it more than once.
# Jar Package with Dependencies
If developers:
- have not modified the content of the
resourceslabel. - develop the module of where the
sermant.basedirparameter correctly points to the top-level directory. - package the project without jar packages with dependencies or package the jar packages with dependencies via
shadeand have not modifiedtransformerslabel.
There is no need to make any adjustments to the output jar package, otherwise please read the instructions below and take it as it is.
In the default packaging process, the current project's default LICENSE file and NOTICE file need to be inserted. These two files are stored in the resources/META-INF directory of the sermant-package module and are specifically pointed to by the resources label.
In general, as long as the sermant.basedir parameter in the packaged module (the packaging label is not pom) points to the top-level directory of the project, these files will be added by default and don't need to be concerned.
When using the shade assembly or spring package plugin to package a jar package with dependencies, if the NOTICE file is included in the **third-party ** jar package, it is best to merge it with the default NOTICE file of current project. ApacheNoticeResourceTransformer of shade plugin just can do this. This is configured in the top-level project's pom file. And it is not recommended to override the top-level project's settings of shade plugin unless you need to modify the Transformer.
Note: The default LICENSE file and NOTICE file mentioned in this section refer to files that only contain information about current project. The LICENSE file and NOTICE file stored in the top-level directory of the project are the files after sorting out the source code copy information, containing information related to current project and the copied third party project information.
# RELEASE Package
The RELEASE package needs to include the LICENSE file of the project source code and the NOTICE file. The former also needs to add the LICENSE information of all the third party jar packages included in the RELEASE package. The RELEASE package also requires third party LICENSE, which are different from the project's LICENSE, to be placed in the licenses directory. The directory is located in the resources directory of the sermant-package module.
To summarize, the internal structure of the RELEASE package looks like this:
agentdirectory: core enhancement logic.serverdirectory: supporting server sides.licensesdirectory: whereLICENSEof third-party-open-source dependencies that are different from the project'sLICENSElocates in.LICENSEfile: the project'sLICENSEfile, which appends a copy of the LICENSE statement of source code of third-party-open-source project, and theLICENSEdescription of alljarpackages of third-party open-source dependencies included in theRELEASEpackage.NOTICEfile: theNOTICEfile of this project, appends theNOTICEfile of source code of third-party-open source project.
This project generates a LICENSE file, a NOTICE file, and a licenses directory for the RELEASEpackage as follows:
- Generate the
LICENSEinformation for all third-partyjarpackages involved in the project via thelicense-maven-plugin:The resulting file,mvn license:aggregate-add-third-partyLICENSE-binary-suffix.txt, is stored in theresourcesdirectory of thesermant-packagemodule. This process takes a long time to execute for the first time, so be patient. - Project components are packaged and exported to a temporary directory.
- When
sermant-packagemodule is packaging, it will:- copy the
LICENSEfile,NOTICEfile, andlicensesdirectory of source code of current project into a temporary directory. - run a script to append the
LICENSE-binary-suffix.txtfile to theLICENSEfile in the temporary directory. - compress the temporary directory to a 'RELEASE' package.
- copy the
To sum up, developers can compile and release the RELEASE package with the following command:
mvn license:aggregate-add-third-party clean package -Dmaven.test.skip
