Why make donate
Update File Header: Configuration

Since version 2.4, without a descriptor file, we can configure the update-file-header goal with four parameters:

To see all extensions accepted run the comment-style-list goal.

[INFO] --- maven-license-plugin:2.4.1:comment-style-list (default-cli) @ maven-license-plugin ---
[INFO] List of available comment styles:

  - apt        : header transformer with apt comment style            , extensions : [apt]
  - java       : header transformer with java comment style           , extensions : [java, groovy, css, cs, as, aj, c, h, cpp]
  - properties : header transformer with properties file comment style, extensions : [properties, sh, py, rb, pl, pm]
  - rst        : header transformer with rst comment style            , extensions : [rst]
  - xml        : header transformer with xml comment style            , extensions : [pom, xml, xhtml, mxlm, dtd, jspx, fml, xsl, html, htm, jaxx, kml, gsp, tml]

Roots

By default, All the files in src are treated. This could be changed with the property roots. The roots property is a list of based directory from which the update-file-header will be applied.

Exemple

Given a pom with these plugin configuration

    <plugins>
      <plugin>
        <groupId>org.nuiton</groupId>
        <artifactId>maven-license-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <verbose>false</verbose>
          <addSvnKeyWords>true</addSvnKeyWords>
        </configuration>
        <executions>
          <execution>
            <id>first</id>
            <goals>
              <goal>update-file-header</goal>
            </goals>
            <phase>process-sources</phase>
            <configuration>
              <licenseName>gpl_v3</licenseName>
              <roots>
                <root>src/main/java</root>
                <root>src/test</root>
              </roots>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  Considering we have the following tree:
  src/main/java
  src/main/resources
  src/test/java
  src/test/resources

Only files from src/main/java, src/test/java and src/test/resources will be treated.

Includes

By default, all the files from the roots and with the adequate extension are treated. With the list parameters includes, we can specify with more precision which files we want to deals.

Example

Soit un pom avec la configuration de plugin suivante:

    <plugins>
      <plugin>
        <groupId>org.nuiton</groupId>
        <artifactId>maven-license-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <verbose>false</verbose>
          <addSvnKeyWords>true</addSvnKeyWords>
        </configuration>
        <executions>
          <execution>
            <id>first</id>
            <goals>
              <goal>update-file-header</goal>
            </goals>
            <phase>process-sources</phase>
            <configuration>
              <licenseName>gpl_v3</licenseName>
              <includes>
                <include>*Dao.java</include>
                <include>*Bean.java</include>
                <include>.*entities.*.xml</include>
              </includes>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>

The update-file-header will be done only on java files (from "src") ending with "Dao" and "Bean" and on xml files containing "entities" in their file name.

Excludes

The excludes parameter allows to ignore some file in the update-file-header process.

Example

Given a pom with these plugin configuration

    <plugins>
      <plugin>
        <groupId>org.nuiton</groupId>
        <artifactId>maven-license-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <verbose>false</verbose>
          <addSvnKeyWords>true</addSvnKeyWords>
        </configuration>
        <executions>
          <execution>
            <id>first</id>
            <goals>
              <goal>update-file-header</goal>
            </goals>
            <phase>process-sources</phase>
            <configuration>
              <licenseName>gpl_v3</licenseName>
              <excludes>
                <exclude>*.png</exclude>
                <exclude>*.txt</exclude>
                <exclude>*Test.java</exclude>
              </excludes>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>

The java files ending with "Test", the png files and the txt files will be ignored by the update-file-header goal.

ExtraExtensions

To use more extensions, add a mapped parameter where keys are extensions and values are the comment style type to use.

Exemple

Given a pom with these plugin configuration

    <plugins>
      <plugin>
        <groupId>org.nuiton</groupId>
        <artifactId>maven-license-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <extraExtensions>
            <yo>java</yo>
          </extraExtensions>
        </configuration>
      </plugin>
    </plugins>

Files with extension yo will be treated as java files.

Maven JRst ReStructuredText