Add Checkstyle plugin and enforce header

This commit is contained in:
filoghost 2020-08-22 19:07:26 +02:00
parent af402447b6
commit c3abd823ed
4 changed files with 56 additions and 0 deletions

14
checkstyle/checkstyle.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="fileExtensions" value="java, xml"/>
<property name="charset" value="UTF-8"/>
<module name="Header">
<property name="fileExtensions" value="java"/>
<property name="headerFile" value="${checkstyle.header.file}"/>
</module>
</module>

5
checkstyle/header.txt Normal file
View File

@ -0,0 +1,5 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/

View File

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress checks="Header" files=".*[\\/]me[\\/]filoghost[\\/]chestcommands[\\/]util[\\/]nbt[\\/].+\.java"/>
</suppressions>

29
pom.xml
View File

@ -154,6 +154,12 @@
<version>3.2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
@ -169,6 +175,29 @@
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>checkstyle/checkstyle.xml</configLocation>
<suppressionsLocation>checkstyle/suppressions.xml</suppressionsLocation>
<headerLocation>checkstyle/header.txt</headerLocation>
<sourceDirectories>
<sourceDirectory>${project.basedir}</sourceDirectory>
</sourceDirectories>
<includes>pom.xml, src/main/java/**/*.java</includes>
</configuration>
<executions>
<execution>
<id>checkstyle-check</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>