Git Product home page Git Product logo

license-parser's Introduction

License Parser

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.

Getting Started

Building the project

Clone the project and just run

mvn package

Then use the generated jar file with dependencies.

How to use it

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

Command line arguments

  • -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.

Replacement tags, template, columns

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%

Custom dependencies JSON

[
    {
        "name": "Dependency name",
        "version": "1.0.5-SNAPSHOT",
        "projectName" : "Optional project name" 
        "source": "https://www.closeit.co/",
        "licenses": [
            {
                "license": "MIT",
                "text": "License text"
            }
        ]
    }
]

License

This project is licensed under the MIT License.

license-parser's People

Contributors

gladosik avatar dependabot[bot] avatar

Stargazers

 avatar Clinton Minton avatar  avatar  avatar

Watchers

James Cloos avatar  avatar Clinton Minton avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.