License Parser is command line tool which creates pretty aggregate of licenses generated by NPM and Maven. Output can be saved to customizable text file or Excel file.
Clone the project and just run
mvn package
Then use the generated jar file with dependencies.
The tool accepts Maven and NPM license reports. In order to generate licenses from NPM, you have to install license-checker. Then generate JSON file with dependencies.
npm install -g license-checker
license-checker --json > npmLicenses.json
Maven has a plugin license-maven-plugin which is able to generate different types of reports. Add the plugin to your pom.xml file and download licenses.
mvn license:download-licenses
This will create licenses.xml file inside folder generated-resources in target together with folder licenses, which contains downloaded license files. Tool will read them too so don't remove this folder.
Run the License Parser and specify file path to json and xml files. Specify also output file names.
java -jar license-parser-1.0-SNAPSHOT-jar-with-dependencies.jar -npmJsonFile "/home/ludek/my-npm-project/license.json" -npmProjectName "My GUI Project" -mavenXmlFile "/home/ludek/my-maven-project/target/generated-resources/licenses.xml" -mavenProjectName "My Maven Project" -outputTextFile licenses.txt -outputExcelFile excel-report.xls
- -customDependenciesJson - JSON string with custom dependencies provided by user. JSON format is described in section Custom dependencies JSON
- -customDependencyFile - path to JSON file with custom dependencies provided by user. JSON format is described in section Custom dependencies JSON
- -npmJsonFile - path to JSON file with dependencies generated by NPM license-checker. Multiple files are supported up to -npmJsonFile5
- -npmProjectName - name of the NPM module/project. Each provided JSON file has a name up to -npmProjectName5
- -mavenXmlFile - path to XML file with dependencies generated by Maven license-maven-plugin. Multiple files are supported up to -mavenXmlFile5
- -mavenProjectName - name of the Maven module/project. Each provided XML file has a name up to -mavenProjectName5
- -outputTextFile - text file which will be generated using default template string. If not provided, file won't be generated.
- -outputExcelFile - Excel file which will be generated. It doesn't contain full license text. If not provided, file won't be generated.
- -textFileDependencyTepmplate - template which defines how to write one dependency to text. Special replacement tags can be used. If provided, it will override default template
- -textFileHeaderTemplate - header text which will be written before the list of dependencies. Special replacement tags can be used. No default value.
- -textFileFooterTemplate - footer text which will be written after the list of dependencies. Special replacement tags can be used. No default value.
- -excelColumns - columns to be written to Excel file. String of replacement tags separated by comma. Default columns are below.
The look of the text file can be adjusted using custom template. Template is used to write each dependency entry. These replacement tags are supported:
- %name% - dependency name
- %version% - dependency version
- %packageManager% - package manager of the dependency. MAVEN or NPM
- %projectName% - name of the dependency project
- %licensesNames% - licenses as provided by authors separated by ,
- %source% - source link of the dependency. It's filled only with NPM licenses
- %license% - full license text provided by author or default license text. Separated by new line.
- %dependencyCount% - count of all dependencies. Can be used in header and footer.
Default template:
%name% %version% - %licensesNames% \n
Source: %source% \n
\n
%license% \n
---------------------------------------------------------------------------------------------------------------\n
Columns in Excel file can also be provided as replacement tags from command line. Default excelColumns value is:
%name%, %version%, %projectName%, %packageManager%, %licensesNames%, %source%
[
{
"name": "Dependency name",
"version": "1.0.5-SNAPSHOT",
"projectName" : "Optional project name"
"source": "https://www.closeit.co/",
"licenses": [
{
"license": "MIT",
"text": "License text"
}
]
}
]
This project is licensed under the MIT License.