Add checkstyle plugin configuration

Not enabled by default because many projects do not use it yet. The
plan is to roll it out and then remove the google import detector.

Fixes gh-58
This commit is contained in:
Dave Syer
2017-08-29 09:36:54 +01:00
parent bea8723caf
commit 3d4369f6cb
3 changed files with 76 additions and 36 deletions

98
pom.xml
View File

@@ -19,11 +19,13 @@
<resource.delimiter>@</resource.delimiter> <!-- delimiter that doesn't clash with Spring ${} placeholders -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<checkstyle.version>2.17</checkstyle.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<main.basedir>${basedir}</main.basedir>
<docs.main>${project.artifactId}</docs.main>
<spring-boot.version>1.5.7.BUILD-SNAPSHOT</spring-boot.version>
<spring-cloud-build.version>1.3.5.BUILD-SNAPSHOT</spring-cloud-build.version>
<!-- Sonar -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
@@ -36,7 +38,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build-dependencies</artifactId>
<version>1.3.5.BUILD-SNAPSHOT</version>
<version>${spring-cloud-build.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -247,6 +249,33 @@ limitations under the License.
<useDefaultDelimiters>false</useDefaultDelimiters>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build-tools</artifactId>
<version>${spring-cloud-build.version}</version>
</dependency>
</dependencies>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<headerLocation>LICENSE.txt</headerLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
@@ -508,6 +537,40 @@ limitations under the License.
</build>
</profile>
<profile>
<id>java7</id>
<activation>
<file>
<missing>.jdk8</missing>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.14</version>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java17</artifactId>
<version>1.0</version>
</signature>
</configuration>
<executions>
<execution>
<id>enforce-java-7</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- TODO: remove this (it's covered with checkstyle, but not all projects use that yet -->
<id>imports</id>
<activation>
<os>
@@ -555,39 +618,6 @@ limitations under the License.
</plugins>
</build>
</profile>
<profile>
<id>java7</id>
<activation>
<file>
<missing>.jdk8</missing>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.14</version>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java17</artifactId>
<version>1.0</version>
</signature>
</configuration>
<executions>
<execution>
<id>enforce-java-7</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>docs</id>
<build>

View File

@@ -13,5 +13,12 @@
<artifactId>spring-cloud-build</artifactId>
<version>1.3.5.BUILD-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>7.6</version>
</dependency>
</dependencies>
</project>

View File

@@ -16,5 +16,8 @@
</module>
<module name="UnusedImports"/>
<module name="RedundantImport"/>
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck" >
<property name="illegalPkgs" value="com.google.common"/>
</module>
</module>
</module>
</module>