Friday, February 26, 2016

Find out license information of all maven dependencies


Buy Moto series phones: Moto E, Moto G, Moto X or Other phones
Buy eBooks from Flipkart
-----------------------------------------------

You want to use a maven dependency and you also need to know about the license information. If it is only one dependency you can easily check it. But each maven dependency more dependencies itself to do its work. That means you have to find out license information of all those jars also.

For example, if you want to use cassandra-unit jar (https://github.com/jsevellec/cassandra-unit) you have to know the license of this jar and 41 other jars also. You see how painful it is. To use one jar you have to find out information of 41 jars, think if you want to use some 10 jars, how many more jars you need to check.

Here maven plugin maven-project-info-reports-plugin comes to the rescue. This plugin can find out all the information you need.

I followed below steps to solve my problem.

Step 1:
I have created a new maven project in the eclipse and added my dependency (cassandra-unit). Then I have added maven-project-info-reports-plugin in the reports section.

Now pom file looks like below.

Step 2

Then run maven goal mvn project-info-reports:dependencies  and it will create a html file at target/site/dependencies.html which gives you all the information you need.

You can see license details of the Maven site plugin


POM.XML

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.reddy</groupId>
    <artifactId>SampleDependencies</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.cassandraunit</groupId>
            <artifactId>cassandra-unit</artifactId>
            <version>2.2.2.1</version>
        </dependency>

    </dependencies>



    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.6</version>
            </plugin>
        </plugins>
    </reporting>



</project>


Latest Posts