blob: 49332bf7484db61e6216f2628dac3fdce7ffb435 [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001if (!project.hasProperty('skipJavaFormat')) {
2 apply plugin: 'checkstyle'
Brian Silverman8fce7482020-01-05 13:18:21 -08003
Austin Schuh812d0d12021-11-04 20:16:48 -07004 checkstyle {
James Kuszmaulb13e13f2023-11-22 20:44:04 -08005 toolVersion = "10.12.2"
Austin Schuh812d0d12021-11-04 20:16:48 -07006 configDirectory = file("${project.rootDir}/styleguide")
7 config = resources.text.fromFile(new File(configDirectory.get().getAsFile(), "checkstyle.xml"))
8 }
Brian Silverman8fce7482020-01-05 13:18:21 -08009
Brian Silverman8fce7482020-01-05 13:18:21 -080010 apply plugin: 'pmd'
11
12 pmd {
James Kuszmaulb13e13f2023-11-22 20:44:04 -080013 toolVersion = '6.55.0'
Brian Silverman8fce7482020-01-05 13:18:21 -080014 consoleOutput = true
15 reportsDir = file("$project.buildDir/reports/pmd")
16 ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml"))
17 ruleSets = []
18 }
Austin Schuh812d0d12021-11-04 20:16:48 -070019
20 apply plugin: 'com.diffplug.spotless'
21
22 spotless {
23 java {
24 target fileTree('.') {
25 include '**/*.java'
James Kuszmaulb13e13f2023-11-22 20:44:04 -080026 exclude '**/build/**', '**/build-*/**', '**/bin/**'
Austin Schuh812d0d12021-11-04 20:16:48 -070027 }
28 toggleOffOn()
29 googleJavaFormat()
30 removeUnusedImports()
31 trimTrailingWhitespace()
32 endWithNewline()
33 }
34 groovyGradle {
35 target fileTree('.') {
36 include '**/*.gradle'
James Kuszmaulb13e13f2023-11-22 20:44:04 -080037 exclude '**/build/**', '**/build-*/**', '**/bin/**'
Austin Schuh812d0d12021-11-04 20:16:48 -070038 }
39 greclipse()
40 indentWithSpaces(4)
41 trimTrailingWhitespace()
42 endWithNewline()
43 }
James Kuszmaulb13e13f2023-11-22 20:44:04 -080044 json {
45 target fileTree('.') {
46 include '**/*.json'
47 exclude '**/build/**', '**/build-*/**', '**/bin/**'
48 exclude '**/simgui-ds.json', '**/simgui-window.json', '**/simgui.json', '**/networktables.json'
49 }
50 gson()
51 .indentWithSpaces(2)
52 }
Austin Schuh812d0d12021-11-04 20:16:48 -070053 format 'xml', {
54 target fileTree('.') {
55 include '**/*.xml'
James Kuszmaulb13e13f2023-11-22 20:44:04 -080056 exclude '**/build/**', '**/build-*/**', '**/bin/**', '**/.idea/**', '**/.run/**'
Austin Schuh812d0d12021-11-04 20:16:48 -070057 }
58 eclipseWtp('xml')
59 trimTrailingWhitespace()
60 indentWithSpaces(2)
61 endWithNewline()
62 }
63 format 'misc', {
64 target fileTree('.') {
65 include '**/*.md', '**/.gitignore'
James Kuszmaulb13e13f2023-11-22 20:44:04 -080066 exclude '**/build/**', '**/build-*/**', '**/bin/**'
Austin Schuh812d0d12021-11-04 20:16:48 -070067 }
68 trimTrailingWhitespace()
69 indentWithSpaces(2)
70 endWithNewline()
71 }
72 }
73
74 apply plugin: 'com.github.spotbugs'
75
76 spotbugs {
77 ignoreFailures = false
78 effort = 'max'
79 excludeFilter = file("${project.rootDir}/styleguide/spotbugs-exclude.xml")
80 }
Brian Silverman8fce7482020-01-05 13:18:21 -080081}
Austin Schuh1e69f942020-11-14 15:06:14 -080082
83task javaFormat {
84 dependsOn(tasks.withType(Checkstyle))
85 dependsOn(tasks.withType(Pmd))
86}
Austin Schuh812d0d12021-11-04 20:16:48 -070087javaFormat.dependsOn 'spotlessApply'