Using with the License Plugin

Overview

This is a tip on using the buildmetadata-plugin with the maven-license-plugin.

To use the build.copyright.year property with the maven-license-plugin, the buildmetadata-plugin has to be run in the same build execution. Use the following tip to run the

license:format
goal successfully.

Configuration

The maven-buildmetadata-plugin is configured to run in the initialize phase.

<plugin>
  <groupId>de.smartics.maven.plugin</groupId>
  <artifactId>maven-buildmetadata-plugin</artifactId>
  <version>${project.version}</version>
  <executions>
    <execution>
      <phase>initialize</phase>
      <goals>
        <goal>provide-buildmetadata</goal>
      </goals>
    </execution>
  </executions>
</plugin>

The license plugin uses the copyright year property provided by the buildmetadata-plugin.

<plugin>
  <groupId>com.mycila.maven-license-plugin</groupId>
  <artifactId>maven-license-plugin</artifactId>
  <version>1.9.0</version>
  <configuration>
    ...
    <properties>
      <year>\${build.copyright.year}</year>
    </properties>
    ...
</plugin>

Run the Build

Run the build by typing

mvn initialize license:format