11plugins {
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+
813def properties (String key ) {
914 return providers. gradleProperty(key)
1015}
@@ -15,6 +20,7 @@ def environment(String key) {
1520
1621apply plugin : ' org.jetbrains.intellij'
1722apply plugin : ' java'
23+ apply plugin : ' checkstyle'
1824
1925// Add plugin group and version
2026group = 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)
2942dependencies {
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
6287tasks. withType(JavaCompile ). configureEach {
0 commit comments