Why make donate
Usage

License

The projects offers some goals to deal with license in a project.

update-project-license goal

This goal creates or updates the LICENSE.txt file and add it in build.

It can also generate a bundle License file to avoid name collision in a final application.

for full detail see detail page.

update-file-header goal

This goal adds or updates the license header on some files using a xml descriptor file to describe all files to include in license process for a whole module.

for full detail see detail page.

configuration

In case of any descriptor file, all the *.java *.rst *.xml et *.properties files from "src/**/*" are treated. However, it is necessary to give the license to use, with the parameter licenseName.

for full detail see detail page.

Third-party

The project offers some goals to deal with THIRD-PARTY files in a project.

add-third-party goal

This goal build the THIRD-PARTY.txt file and add it in build.

Since version 2.3, we can consolidate the generated file by filling another file (the missing file) for dependencies without license.

Note: This mojo has not effect on a pom project.

for full detail see detail page.

aggregate-add-third-party goal

This goal build the THIRD-PARTY.txt file on a multi-module project from the dependencies of all his modules.

Note: This mojo has only effect on a pom project.

for full detail see detail page.

How to consolidate the THIRD-PARTY file

It is possible to improve the THIRD-PARTY file :

- Fill back missing license for dependencies.

- Merge licenses (same license but named differently in dependencies poms).

Add missing licenses.

While using configuration's property useMissingfile on third-party goals, it will create (or read for aggregate) a file located from property missingFile (by default src/license/THIRD-PARTY.properties).

In this file, we find dependencies with no license, you just have to fill correct licenses.

Once the file filled, just relaunch the goal to integrate your modifications in the generated THIRD-PARTY file.

Example

Given a pom with these dependencies :

  <dependencies>

    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.1</version>
    </dependency>

    <dependency>
      <groupId>commons-primitives</groupId>
      <artifactId>commons-primitives</artifactId>
      <version>1.0</version>
    </dependency>

  </dependencies>

Here is a THIRD-PARTY file with unnamed licenses launched by

mvn license:add-third-party -DuseMissingFile

List of 2 third-party dependencies.

 (The Apache Software License, Version 2.0) Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)
 (Unknown license) Unnamed - commons-primitives:commons-primitives:jar:1.0 (commons-primitives:commons-primitives:1.0 - no url defined)

And the generated THIRD-PARTY.properties file :

# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
# - The Apache Software License, Version 2.0
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
#Fri Jun 25 10:56:39 CEST 2010
commons-primitives--commons-primitives--1.0=

Fills the file :

# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
# - The Apache Software License, Version 2.0
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
#Fri Jun 25 10:56:39 CEST 2010
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0

Finally, relaunch the goal to obtain new generated THIRD-PARTY.txt file :

List of 2 third-party dependencies.

 (The Apache Software License, Version 2.0) Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)
 (The Apache Software License, Version 2.0) Unnamed - commons-primitives:commons-primitives:jar:1.0 (commons-primitives:commons-primitives:1.0 - no url defined)

Merge licenses.

To merge licenses added in THIRd-PARTY file, you have to add a licenseMerges to the plugin this configuration :

Each entry of licenseMerges describe a merge, the first license is the one to keep.

Example

Given a pom with these dependencies :

  <dependencies>

    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.1</version>
    </dependency>

    <dependency>
      <groupId>com.jhlabs</groupId>
      <artifactId>filters</artifactId>
      <version>2.0.235</version>
    </dependency>

  </dependencies>

While executing add-third-party goal, we obtain the following THIRD-PARTY file :

List of 2 third-party dependencies.

 (Apache License, Version 2.0) JHLabs Image Processing Filters (com.jhlabs:filters:2.0.235 - http://www.jhlabs.com/ip/index.html)
 (The Apache Software License, Version 2.0) Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)

Now, adds this configuration in your pom

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.nuiton</groupId>
          <artifactId>maven-license-plugin</artifactId>
          <version>2.3</version>
          <executions>
            <execution>
              <id>default-cli</id>
              <configuration>
                <licenseMerges>
                  <licenseMerge>The Apache Software License, Version 2.0|Apache License, Version 2.0</licenseMerge>
                </licenseMerges>
              </configuration>
            </execution>
          </executions>
        </plugin>
        ...
      </plugins>
    </pluginManagement>

and relaunch the goal, we now obtain the following THIRD-PARTY file :

List of 2 third-party dependencies.

 (The Apache Software License, Version 2.0) Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)
 (The Apache Software License, Version 2.0) JHLabs Image Processing Filters (com.jhlabs:filters:2.0.235 - http://www.jhlabs.com/ip/index.html)

Filter the dependencies

Since version 2.3, we can consolidate the THIRD-PARTY file with filters on artifacts and groups, in excluding or only including some of them.

  • Include ArtifactIds or GroupIds

    Include property is useful to refer in THIRD-PARTY file only some artifacts, given by their artifactIds and those that are in the given groupIds.

  • Exclude ArtifactIds or GroupIds

    Exclude property is useful to not refer in THIRD-PARTY file only some artifacts, given by their artifactIds and those that are in the given groupIds.

  • Include - Exclude : priority

    Note that the exclude filter is predominant on include filter. So, if we include an artifact but exclude its groupId, it will not be referred in THIRD-PARTY file.

exclude groupIds

While using configuration's property excludeGroups on third-party goals, it will remove all the dependencies came from the given groupIds fom the THIRD-PARTY file.

Example

Given a pom with these dependencies :

  <dependencies>

    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.1</version>
    </dependency>

    <dependency>
      <groupId>com.jhlabs</groupId>
      <artifactId>filters</artifactId>
      <version>2.0.235</version>
    </dependency>

    <dependency>
      <groupId>com.jhlabs</groupId>
      <artifactId>javaproj</artifactId>
      <version>1.0</version>
    </dependency<

  </dependencies>

While executing mvn add-third-party -Dlicense.excludedGroups=com\.jhla.*, we obtain the following THIRD-PARTY file :

List of 2 third-party dependencies.

 (The Apache Software License, Version 2.0) Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)

exclude artifactIds

While using configuration's property excludeArtifacts on third-party goals, it will remove all the dependencies came from the given artifactsIds fom the THIRD-PARTY file.

Example

Given a pom with these dependencies :

  <dependencies>

    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.1</version>
    </dependency>

    <dependency>
      <groupId>com.jhlabs</groupId>
      <artifactId>filters</artifactId>
      <version>2.0.235</version>
    </dependency>

    <dependency>
      <groupId>com.jhlabs</groupId>
      <artifactId>javaproj</artifactId>
      <version>1.0</version>
    </dependency<

  </dependencies>

While executing mvn add-third-party -Dlicense.excludedArtifacts=javaproj, we obtain the following THIRD-PARTY file :

List of 2 third-party dependencies.

  (Apache License, Version 2.0) JHLabs Image Processing Filters (com.jhlabs:filters:2.0.235 - http://www.jhlabs.com/ip/index.html)
  (The Apache Software License, Version 2.0) Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)

include groupIds

While using configuration's property includeGroups on third-party goals, it will include only the dependencies came from the given groupIds fom the THIRD-PARTY file.

Example

Given a pom with these dependencies :

  <dependencies>

    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.1</version>
    </dependency>

    <dependency>
      <groupId>com.jhlabs</groupId>
      <artifactId>filters</artifactId>
      <version>2.0.235</version>
    </dependency>

    <dependency>
      <groupId>com.jhlabs</groupId>
      <artifactId>javaproj</artifactId>
      <version>1.0</version>
    </dependency<

  </dependencies>

While executing mvn add-third-party -Dlicense.includedGroups=com\.jhlabs, we obtain the following THIRD-PARTY file :

List of 2 third-party dependencies.

  (Apache License, Version 2.0) JHLabs Image Processing Filters (com.jhlabs:filters:2.0.235 - http://www.jhlabs.com/ip/index.html)
  (The Apache Software License, Version 2.0) JHlabs Java Projection Library (com.jhlabs:javaproj:1.0 - http://www.jhlabs.com/java/maps/proj/index.html)

include artifactIds

While using configuration's property excludeArtifacts on third-party goals, it will include only the dependencies came from the given artifactIds fom the THIRD-PARTY file.

Example

Given a pom with these dependencies :

  <dependencies>

    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.1</version>
    </dependency>

    <dependency>
      <groupId>com.jhlabs</groupId>
      <artifactId>filters</artifactId>
      <version>2.0.235</version>
    </dependency>

    <dependency>
      <groupId>com.jhlabs</groupId>
      <artifactId>javaproj</artifactId>
      <version>1.0</version>
    </dependency<

  </dependencies>

While executing mvn add-third-party -Dlicense.includedArtifacts=filters, we obtain the following THIRD-PARTY file :

List of 2 third-party dependencies.

  (Apache License, Version 2.0) JHLabs Image Processing Filters (com.jhlabs:filters:2.0.235 - http://www.jhlabs.com/ip/index.html)

Get informations

license-list goal

This goal display of available licenses.

Use it directly (and only) from commandline :

  mvn license:license-list

To display the license header, use the detail parameter :

  mvn license:license-list -Ddetail

for full detail see detail page.

Example of execution

  [INFO] [license:license-list {execution: default-cli}]
  [INFO] Available licenses :

   * agpl_v3   : GNU Affero General Public License (AGPL) version 3.0
   * apache_v2 : Apache License version 2.0
   * cddl_v1   : COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
   * fdl_v1_3  : GNU Free Documentation License (FDL) version 1.3
   * gpl_v1    : GNU General Public License (GPL) version 1.0
   * gpl_v2    : GNU General Public License (GPL) version 2.0
   * gpl_v3    : GNU General Public License (GPL) version 3.0
   * lgpl_v2_1 : GNU General Lesser Public License (LGPL) version 2.1
   * lgpl_v3   : GNU General Lesser Public License (LGPL) version 3.0
   * mit       : MIT-License

comment-style-list goal

This goal display of available comment style to box file header.

Use it directly (and only) from commandline :

  mvn license:comment-style-list

To display the example, use the detail parameter :

  mvn license:comment-style-list -Ddetail

for full detail see detail page.

Example of execution

  [INFO] [license:comment-style-list {execution: default-cli}]
  [INFO] List of available comment styles:

    - apt        : header transformer with apt comment style
    - java       : header transformer with java comment style
    - properties : header transformer with properties file comment style
    - rst        : header transformer with rst comment style
    - xml        : header transformer with xml comment style

help goal

This goal display the help of the plugin (available goals).

Use it directly (and only) from commandline :

  mvn license:help

To display verbose help :

  mvn license:help -Ddetail

for full detail see detail page.

Maven JRst ReStructuredText