I have a multi-module project in which I’m trying to set up the license plugin to manage all the licenses. Here’s the project setup:
─── transfuse-project
├── examples
│ ├── helloAndroid
│ │ ├── pom.xml
│ │ ├── ...
│ ├── integrationTest
│ │ ├── pom.xml
│ │ ├── ...
│ ├── pom.xml
│ └── ...
├── transfuse
│ ├── pom.xml
│ ├── ...
├── transfuse-api
│ ├── pom.xml
│ ├── ...
├── NOTICE
└── pom.xml
Each pom.xml inherits from the transfuse-project pom.xml. In the project pom.xml I have set up the license plugin to apply the NOTICE to the relevant files:
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.9.0</version>
<configuration>
<header>NOTICE</header>
<includes>
<include>**/*.java</include>
<include>**/*.xml</include>
</includes>
<excludes>
<exclude>**/.*/**</exclude>
<exclude>target/**</exclude>
<exclude>**/AndroidManifest.xml</exclude>
</excludes>
<properties>
<year>2013</year>
<name>John Ericksen</name>
</properties>
<useDefaultExcludes>true</useDefaultExcludes>
<strictCheck>true</strictCheck>
</configuration>
<executions>
<execution>
<id>check-headers</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
This configuration works if I build directly off of the root (transfuse-project). The problem arises when I build the integrationTest example or api directly. Maven cannot find the NOTICE file I provided in the project root:
[ERROR] Failed to execute goal com.mycila.maven-license-plugin:maven-license-plugin:1.9.0:check (check-headers) on project transfuse-api: Some files do not have the expected license header -> [Help 1]
And what’s worse, it finds another dependency’s NOTICE file. If I run mvn license:format in a sub-module it replaces all of the module’s headers with the dependency’s NOTICE file.
I believe I can add a NOTICE file within each sub-module to fix this problem and configure each sub-module pom with its own license plugin, but I would like to avoid that duplication if possible. Is there some configuration or setup that will work with my project setup?
Try to use an absolute path by using
If this doesn’t work, try to set a property to and in the parent module’s basedir and use it:
A third option is setting a property at runtime:
Edit:
Ok, a whole other option is to execute the maven-dependency-plugin before your license plugin. But you have to make sure the parent attaches the NOTICE (with maven-assembly-plugin plugin)
The
headerchanges then in:Edit2:
I came across the find-maven-plugin. I think this could work: