Add JavaFormat Checkstyle to Build
Issue gh-744
This commit is contained in:
16
build.gradle
16
build.gradle
@@ -17,7 +17,7 @@ buildscript {
|
||||
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.28.2"
|
||||
classpath 'org.hidetake:gradle-ssh-plugin:2.10.1'
|
||||
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0'
|
||||
classpath 'io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.38'
|
||||
classpath "io.spring.javaformat:spring-javaformat-gradle-plugin:$springJavaformatVersion"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +67,22 @@ s101 {
|
||||
allprojects {
|
||||
if (!['spring-ldap-bom', 'spring-security-docs'].contains(project.name)) {
|
||||
apply plugin: 'io.spring.javaformat'
|
||||
apply plugin: 'checkstyle'
|
||||
|
||||
pluginManager.withPlugin("io.spring.convention.checkstyle", { plugin ->
|
||||
configure(plugin) {
|
||||
dependencies {
|
||||
checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:$springJavaformatVersion"
|
||||
}
|
||||
checkstyle {
|
||||
toolVersion = '8.34'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (project.name.contains('sample')) {
|
||||
tasks.whenTaskAdded { task ->
|
||||
if (task.name.contains('format') || task.name.contains('checkFormat')) {
|
||||
if (task.name.contains('format') || task.name.contains('checkFormat') || task.name.contains('checkstyle')) {
|
||||
task.enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
46
etc/checkstyle/checkstyle-suppressions.xml
Normal file
46
etc/checkstyle/checkstyle-suppressions.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE suppressions PUBLIC
|
||||
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
|
||||
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
|
||||
<suppressions>
|
||||
<suppress files=".*" checks="JavadocMethod" />
|
||||
<suppress files=".*" checks="JavadocStyle" />
|
||||
<suppress files=".*" checks="JavadocTagContinuationIndentation" />
|
||||
<suppress files=".*" checks="JavadocType" />
|
||||
<suppress files=".*" checks="JavadocVariable" />
|
||||
<suppress files=".*" checks="NonEmptyAtclauseDescription" />
|
||||
<suppress files=".*" checks="SpringJavadoc" />
|
||||
|
||||
<!-- generated -->
|
||||
<suppress files="[\\/]generated[\\/]javacc[\\/]" checks="[a-zA-Z0-9]*"/>
|
||||
|
||||
<!-- Ignore third-party code -->
|
||||
<suppress files="BCrypt\.java|BCryptTests\.java" checks=".*"/>
|
||||
<suppress files="org[\\/]springframework[\\/]security[\\/]core[\\/]ComparableVersion\.java" checks=".*"/>
|
||||
|
||||
<!-- Method Visibility that we can't reduce -->
|
||||
<suppress files="AbstractAclVoterTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="AbstractSecurityWebSocketMessageBrokerConfigurerTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="AnnotationParameterNameDiscovererTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="AnnotationSecurityAspectTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="AuthenticationPrincipalArgumentResolverTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="ELRequestMatcherContext\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="EnableWebFluxSecurityTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="ExpressionBasedPreInvocationAdviceTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="ExpressionUrlAuthorizationConfigurerTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="Jsr250MethodSecurityMetadataSourceTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="MapBasedMethodSecurityMetadataSourceTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="OAuth2ResourceServerBeanDefinitionParserTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="ObjectIdentityImplTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="ObjectIdentityRetrievalStrategyImplTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="ProtectPointcutPostProcessor\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="ReactiveMethodSecurityConfigurationTests" checks="SpringMethodVisibility"/>
|
||||
<suppress files="WebSocketMessageBrokerConfigTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="WebSecurityConfigurationTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="WithSecurityContextTestExecutionListenerTests\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="AbstractOAuth2AuthorizationGrantRequestEntityConverter\.java" checks="SpringMethodVisibility"/>
|
||||
<suppress files="JoseHeader\.java" checks="SpringMethodVisibility"/>
|
||||
|
||||
<!-- Lambdas that we can't replace with a method reference because a closure is required -->
|
||||
<suppress files="BearerTokenAuthenticationFilter\.java" checks="SpringLambda"/>
|
||||
</suppressions>
|
||||
30
etc/checkstyle/checkstyle.xml
Normal file
30
etc/checkstyle/checkstyle.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
<module name="com.puppycrawl.tools.checkstyle.Checker">
|
||||
<module name="SuppressionFilter">
|
||||
<property name="file"
|
||||
value="${config_loc}/checkstyle-suppressions.xml" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.header.RegexpHeaderCheck">
|
||||
<property name="headerFile" value="${config_loc}/header.txt" />
|
||||
<property name="fileExtensions" value="java" />
|
||||
</module>
|
||||
<module name="io.spring.javaformat.checkstyle.SpringChecks">
|
||||
<property name="excludes" value="io.spring.javaformat.checkstyle.check.SpringHeaderCheck" />
|
||||
<property name="excludes" value="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck" />
|
||||
<property name="avoidStaticImportExcludes" value="org.springframework.security.test.web.servlet.response.SecurityMockMvcResultHandlers.*" />
|
||||
<property name="avoidStaticImportExcludes" value="org.springframework.security.web.util.matcher.AntPathRequestMatcher.*" />
|
||||
<property name="avoidStaticImportExcludes" value="org.springframework.security.web.util.matcher.RegexRequestMatcher.*" />
|
||||
<property name="avoidStaticImportExcludes" value="org.springframework.core.annotation.MergedAnnotations.SearchStrategy.*" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.TreeWalker">
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
|
||||
<property name="maximum" value="0"/>
|
||||
<property name="format" value="org\.assertj\.core\.api\.Assertions\.(catchThrowable|catchThrowableOfType|assertThatThrownBy|assertThatCode)" />
|
||||
<property name="message" value="Please use assertThatExceptionOfType." />
|
||||
<property name="ignoreComments" value="true" />
|
||||
</module>
|
||||
</module>
|
||||
</module>
|
||||
16
etc/checkstyle/header.txt
Normal file
16
etc/checkstyle/header.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
^\Q/*\E$
|
||||
^\Q * Copyright \E20\d\d-20\d\d the original author or authors.$
|
||||
^\Q *\E$
|
||||
^\Q * Licensed under the Apache License, Version 2.0 (the "License");\E$
|
||||
^\Q * you may not use this file except in compliance with the License.\E$
|
||||
^\Q * You may obtain a copy of the License at\E$
|
||||
^\Q *\E$
|
||||
^\Q * https://www.apache.org/licenses/LICENSE-2.0\E$
|
||||
^\Q *\E$
|
||||
^\Q * Unless required by applicable law or agreed to in writing, software\E$
|
||||
^\Q * distributed under the License is distributed on an "AS IS" BASIS,\E$
|
||||
^\Q * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\E$
|
||||
^\Q * See the License for the specific language governing permissions and\E$
|
||||
^\Q * limitations under the License.\E$
|
||||
^\Q */\E$
|
||||
^$
|
||||
@@ -1,2 +1,3 @@
|
||||
version=3.1.0-SNAPSHOT
|
||||
springJavaformatVersion=0.0.38
|
||||
org.gradle.caching=true
|
||||
|
||||
Reference in New Issue
Block a user