Skip to content

Commit ed294ec

Browse files
committed
Run checkstyle checks in workflow
1 parent 71a7cb4 commit ed294ec

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

.config/checkstyle/checkstyle.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<property name="tabWidth" value="4"/>
1010

1111
<module name="SuppressionFilter">
12-
<property name="file" value=".config/checkstyle/suppressions.xml"/>
12+
<property name="file" value="${config_loc}/suppressions.xml"/>
1313
</module>
1414

1515
<module name="FileLength"/>

.github/workflows/checkBuild.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,24 @@ jobs:
6464
name: plugin-files-java-${{ matrix.java }}
6565
path: build/libs/intellij-plugin-save-actions-*.jar
6666
if-no-files-found: error
67+
68+
code-style:
69+
runs-on: ubuntu-latest
70+
71+
strategy:
72+
matrix:
73+
java: [17]
74+
distribution: [temurin]
75+
76+
steps:
77+
- uses: actions/checkout@v4
78+
79+
- name: Set up JDK
80+
uses: actions/setup-java@v4
81+
with:
82+
distribution: ${{ matrix.distribution }}
83+
java-version: ${{ matrix.java }}
84+
cache: 'gradle'
85+
86+
- name: Run Checkstyle
87+
run: ./gradlew checkstyleMain checkstyleTest -PcheckstyleEnabled=true

build.gradle

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
plugins {
22
id 'java'
33
id 'idea'
4+
id 'checkstyle'
45
id 'org.jetbrains.intellij' version '1.17.1'
56
id 'org.sonarqube' version '4.4.1.3373'
67
}
78

9+
ext {
10+
checkstyleVersion = '10.13.0'
11+
}
12+
813
def properties(String key) {
914
return providers.gradleProperty(key)
1015
}
@@ -15,6 +20,7 @@ def environment(String key) {
1520

1621
apply plugin: 'org.jetbrains.intellij'
1722
apply plugin: 'java'
23+
apply plugin: 'checkstyle'
1824

1925
// Add plugin group and version
2026
group = properties("pluginGroup").get()
@@ -25,8 +31,16 @@ repositories {
2531
mavenCentral()
2632
}
2733

34+
// https://github.com/gradle/gradle/issues/27035
35+
configurations.checkstyle {
36+
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
37+
select("com.google.guava:guava:0")
38+
}
39+
}
40+
2841
// Add dependencies to test, junit5 api (annotations) and engine (runtime)
2942
dependencies {
43+
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
3044
testImplementation platform('org.junit:junit-bom:5.10.2'),
3145
'org.junit.jupiter:junit-jupiter',
3246
'org.junit.jupiter:junit-jupiter-engine',
@@ -57,6 +71,17 @@ listProductsReleases {
5771
sinceBuild = "223.*"
5872
}
5973

74+
checkstyle {
75+
configDirectory = file("$rootProject.projectDir/.config/checkstyle")
76+
ignoreFailures false
77+
showViolations true
78+
toolVersion = checkstyleVersion
79+
}
80+
81+
tasks.withType(Checkstyle).configureEach {
82+
enabled = project.hasProperty("checkstyleEnabled");
83+
}
84+
6085
// Configure compileJava AND compileTestJava
6186
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.compile.JavaCompile.html
6287
tasks.withType(JavaCompile).configureEach {

0 commit comments

Comments
 (0)