Skip to content

Commit 30a1f02

Browse files
committed
build: add support for checkstyle / spotless to grails-core
1 parent cc44ab0 commit 30a1f02

File tree

8 files changed

+82
-16
lines changed

8 files changed

+82
-16
lines changed

buildSrc/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ dependencies {
5252
implementation 'io.github.gradle-nexus:publish-plugin'
5353
implementation 'org.apache.grails:grails-docs-core'
5454
implementation 'org.apache.grails:grails-gradle-plugins'
55+
implementation "com.diffplug.spotless:spotless-plugin-gradle:${gradleProperties.spotlessVersion}"
56+
implementation "io.spring.nohttp:nohttp-gradle:${gradleProperties.nohttpGradleVersion}"
5557
implementation 'org.asciidoctor:asciidoctor-gradle-jvm'
5658
implementation 'org.springframework.boot:spring-boot-gradle-plugin'
5759
implementation 'org.nosphere.apache.rat:org.nosphere.apache.rat.gradle.plugin:0.8.1'

grails-forge/config/checkstyle/checkstyle.xml renamed to etc/config/checkstyle/checkstyle.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@
9797
<module name="SuppressWarningsFilter"/>
9898

9999
<!-- See http://checkstyle.sourceforge.net/config_filters.html#SuppressionFilter -->
100-
<module name="SuppressionFilter">
101-
<property name="file" value="${config_loc}/suppressions.xml"/>
102-
<property name="optional" value="false"/>
103-
</module>
100+
<!-- <module name="SuppressionFilter">-->
101+
<!-- <property name="file" value="${config_loc}/suppressions.xml"/>-->
102+
<!-- <property name="optional" value="false"/>-->
103+
<!-- </module>-->
104104

105105
<module name="TreeWalker">
106106

@@ -114,6 +114,8 @@
114114
<property name="allowMissingReturnTag" value="true"/>
115115
</module>
116116
<module name="JavadocType">
117+
<!-- https://github.com/checkstyle/checkstyle/issues/14581 -->
118+
<property name="allowMissingParamTags" value="true"/>
117119
</module>
118120

119121
<module name="JavadocStyle">

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ yakworksHibernateGroovyProxyVersion=1.1
4040
picocliVersion=4.7.6
4141
liquibaseHibernate5Version=4.27.0
4242
hibernate5Version=5.6.15.Final
43+
spotlessVersion=6.25.0
44+
nohttpGradleVersion=0.0.11
4345

4446
githubSlug=apache/grails-core
4547
githubBranch=7.0.x
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
apply plugin: 'checkstyle'
21+
apply plugin: 'com.diffplug.spotless'
22+
apply plugin: 'io.spring.nohttp' // enforce https everywhere
23+
24+
spotless {
25+
java {
26+
licenseHeaderFile(rootProject.file("etc/config/spotless/license.java"))
27+
target('src/main/java/**/*.java')
28+
}
29+
groovy {
30+
licenseHeaderFile(rootProject.file("etc/config/spotless/license.java"))
31+
target('src/main/groovy/**.groovy', 'src/main/groovy/**.java')
32+
}
33+
format 'javaMisc', {
34+
target('src/main/**/package-info.java', 'src/main/**/module-info.java')
35+
licenseHeaderFile(rootProject.file('etc/config/spotless/license.java'), '\\/\\*\\*')
36+
}
37+
}
38+
39+
checkstyle {
40+
configFile = project.rootProject.file('etc/config/checkstyle/checkstyle.xml')
41+
42+
// Per submodule
43+
maxErrors = 1
44+
maxWarnings = 10
45+
46+
showViolations = true
47+
}
48+
49+
nohttp {
50+
source.exclude('src/test/**', 'build/**')
51+
}
52+
53+
if (tasks.names.contains('checkstyleTest')) {
54+
tasks.named('checkstyleTest').configure {
55+
it.group = 'verification'
56+
it.enabled = false
57+
}
58+
}
59+
60+
if (tasks.names.contains('checkstyleMain')) {
61+
tasks.named('checkstyleMain').configure {
62+
it.group = 'verification'
63+
it.dependsOn('spotlessCheck')
64+
}
65+
}

grails-forge/config/checkstyle/suppressions.xml renamed to grails-forge/etc/checkstyle/suppressions.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
<!DOCTYPE suppressions PUBLIC
2323
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
2424
"http://checkstyle.sourceforge.net/dtds/suppressions_1_1.dtd">
25-
2625
<suppressions>
27-
<suppress checks="FileLength"
28-
files="DefaultBeanContext.java|BeanDefinitionWriter.java|DefaultHttpClient.java"/>
29-
<suppress files="[\\/]generated-src[\\/]|RockerSubs.java" checks="[a-zA-Z0-9]*"/>
30-
<suppress checks="Nohttp" files="pom.xml" />
26+
<!-- <suppress checks="FileLength"-->
27+
<!-- files="DefaultBeanContext.java|BeanDefinitionWriter.java|DefaultHttpClient.java"/>-->
28+
<!-- <suppress files="[\\/]generated-src[\\/]|RockerSubs.java" checks="[a-zA-Z0-9]*"/>-->
3129
</suppressions>

grails-forge/gradle.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ micronautBuildVersion=1.1.5
4343
micronautDocsVersion=2.0.0
4444
micronautGradlePlugins=5.4.10
4545
micronautVersion=3.10.4
46-
nexusPublishVersion=1.3.0
47-
nohttpGradleVersion=0.0.11
4846
objenesisVersion=3.4
4947
picocliVersion=4.7.5
5048
postgresqlVersion=42.7.5
@@ -55,7 +53,6 @@ shadowVersion=8.3.6
5553
slf4jVersion=2.0.17
5654
snakeyamlVersion=2.4
5755
spockVersion=2.1-groovy-3.0
58-
spotlessVersion=6.25.0
5956
testRetryVersion=1.6.2
6057
typesafeConfigVersion=1.4.3
6158

grails-forge/gradle/style-enforcement-config.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ apply plugin: 'io.spring.nohttp' // enforce https everywhere
2323

2424
spotless {
2525
java {
26-
licenseHeaderFile(rootProject.file("${rootDir}/config/spotless.license.java"))
26+
licenseHeaderFile(rootProject.file("../etc/config/spotless/license.java"))
2727
target('src/main/java/**/*.java')
2828
}
2929
groovy {
30-
licenseHeaderFile(rootProject.file("${rootDir}/config/spotless.license.java"))
30+
licenseHeaderFile(rootProject.file("../etc/config/spotless/license.java"))
3131
target('src/main/groovy/**')
3232
}
3333
format 'javaMisc', {
3434
target('src/main/**/package-info.java', 'src/main/**/module-info.java')
35-
licenseHeaderFile(rootProject.file('config/spotless.license.java'), '\\/\\*\\*')
35+
licenseHeaderFile(rootProject.file('../etc/config/spotless/license.java'), '\\/\\*\\*')
3636
}
3737
}
3838

3939
checkstyle {
40-
configFile = project.rootProject.file('config/checkstyle/checkstyle.xml')
40+
configFile = project.rootProject.file('etc/config/checkstyle/checkstyle.xml')
4141

4242
// Per submodule
4343
maxErrors = 1

0 commit comments

Comments
 (0)