Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gradle Checkstyle #1444

Merged
merged 3 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ plugins {
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.4'
id 'org.graalvm.buildtools.native' version '0.9.28'
id 'io.spring.javaformat' version '0.0.40'
id 'io.spring.javaformat' version '0.0.41'
id "io.spring.nohttp" version "0.0.11"
}

apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: 'io.spring.javaformat'

gradle.startParameter.excludedTaskNames += [ "checkFormatAot", "checkFormatAotTest" ]
Expand Down Expand Up @@ -43,8 +45,35 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-docker-compose'
testImplementation 'org.testcontainers:junit-jupiter'
testImplementation 'org.testcontainers:mysql'
checkstyle 'io.spring.javaformat:spring-javaformat-checkstyle:0.0.41'
checkstyle 'com.puppycrawl.tools:checkstyle:10.12.5'
}

tasks.named('test') {
useJUnitPlatform()
}

checkstyle {
configDirectory = project.file('src/checkstyle')
configFile = file('src/checkstyle/nohttp-checkstyle.xml')
}

checkstyleNohttp {
configDirectory = project.file('src/checkstyle')
configFile = file('src/checkstyle/nohttp-checkstyle.xml')
}

tasks.named("formatMain").configure { dependsOn("checkstyleMain") }
tasks.named("formatMain").configure { dependsOn("checkstyleNohttp") }

tasks.named("formatTest").configure { dependsOn("checkstyleTest") }
tasks.named("formatTest").configure { dependsOn("checkstyleNohttp") }

checkstyleAot.enabled = false
checkstyleAotTest.enabled = false

checkFormatAot.enabled = false
checkFormatAotTest.enabled = false

formatAot.enabled = false
formatAotTest.enabled = false
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,12 @@
<phase>validate</phase>
<configuration>
<configLocation>src/checkstyle/nohttp-checkstyle.xml</configLocation>
<suppressionsLocation>src/checkstyle/nohttp-checkstyle-suppressions.xml</suppressionsLocation>
<sourceDirectories>${basedir}</sourceDirectories>
<includes>**/*</includes>
<excludes>**/.git/**/*,**/.idea/**/*,**/target/**/,**/.flattened-pom.xml,**/*.class</excludes>
<propertyExpansion>
config_loc=${basedir}/src/checkstyle/
</propertyExpansion>
</configuration>
<goals>
<goal>check</goal>
Expand Down
7 changes: 4 additions & 3 deletions src/checkstyle/nohttp-checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress files="node_modules/.*" checks=".*"/>
<suppress files="node/.*" checks=".*"/>
<suppress files="build/.*" checks=".*"/>
<suppress files="node_modules[\\/].*" checks=".*"/>
<suppress files="node[\\/].*" checks=".*"/>
<suppress files="build[\\/].*" checks=".*"/>
<suppress files="target[\\/].*" checks=".*"/>
<suppress files=".+\.(jar|git|ico|p12|gif|jks|jpg|svg|log)" checks="NoHttp"/>
</suppressions>
3 changes: 3 additions & 0 deletions src/checkstyle/nohttp-checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
"https://checkstyle.org/dtds/configuration_1_2.dtd">
<module name="com.puppycrawl.tools.checkstyle.Checker">
<module name="io.spring.nohttp.checkstyle.check.NoHttpCheck"/>
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/nohttp-checkstyle-suppressions.xml"/>
</module>
</module>