Oui,, Checkstyle (et maven-checkstyle-plugin) peut le faire, il peut vérifier que chaque fichier source contient un en-tête de licence. Mettez cet en-tête dans un fichier texte et utilisez le headerLocation
pour pointer dessus (il utilise par défaut LICENSE.txt
).
Supposons que vous souhaitiez utiliser checkstyle.license
pour vos avis de droits d'auteur. Pour un multi-modules à construire, l'approche standard est de créer un module dédié pour héberger les ressources Checkstyle (voir Multimodule configuration):
whizbang
|-- pom.xml
|-- build-tools
| |-- src
| | `-- main
| | `-- resources
| | `-- whizbang
| | |-- checkstyle.xml
| | `-- checkstyle.license
| `-- pom.xml
|-- core
|-- gui
|-- jmx
`-- src
Ensuite, comprennent le Checkstyle configuration au niveau supérieur pom.xml
.
<pluginManagement>
<plugins>
<!-- Apply checkstyle rules and fail the build in case of errors. The
checkstyle config files are taken from the build-tools JAR module.-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<!-- Lock down plugin version for build reproducibility -->
<version>2.4</version>
<dependencies>
<dependency>
<groupId>com.example.whizbang</groupId>
<artifactId>build-tools</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<configuration>
<consoleOutput>true</consoleOutput>
<configLocation>whizbang/checkstyle.xml</configLocation>
<headerLocation>whizbang/checkstyle.license</headerLocation>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</pluginManagement>
Cette configuration veillera à ce qu'un en-tête du droit d'auteur est présent dans les fichiers sources (et appliquer d'autres règles Checkstyle mais ceci est une autre histoire). Adaptez-le à vos besoins.