blob: 41ddb47e6d0cc967f5f0ee043fd7e608946379b4 [file] [log] [blame]
Maxwell Henderson80bec322024-01-09 15:48:44 -08001if (project.hasProperty('skipJavaFormat')) {
2 return;
3}
Brian Silverman8fce7482020-01-05 13:18:21 -08004
Maxwell Henderson80bec322024-01-09 15:48:44 -08005apply plugin: 'checkstyle'
6
7checkstyle {
8 toolVersion = "10.12.2"
9 configDirectory = file("${project.rootDir}/styleguide")
10 config = resources.text.fromFile(new File(configDirectory.get().getAsFile(), "checkstyle.xml"))
11}
12
13apply plugin: 'pmd'
14
15pmd {
16 toolVersion = '6.55.0'
17 consoleOutput = true
18 reportsDir = file("$project.buildDir/reports/pmd")
19 ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml"))
20 ruleSets = []
21}
22
23apply plugin: 'com.diffplug.spotless'
24
25spotless {
26 java {
27 target fileTree('.') {
28 include '**/*.java'
29 exclude '**/build/**', '**/build-*/**', '**/bin/**', "src/generated/**"
30 }
31 toggleOffOn()
32 googleJavaFormat()
33 removeUnusedImports()
34 trimTrailingWhitespace()
35 endWithNewline()
Austin Schuh812d0d12021-11-04 20:16:48 -070036 }
Maxwell Henderson80bec322024-01-09 15:48:44 -080037 groovyGradle {
38 target fileTree('.') {
39 include '**/*.gradle'
40 exclude '**/build/**', '**/build-*/**', '**/bin/**'
41 }
42 greclipse()
43 indentWithSpaces(4)
44 trimTrailingWhitespace()
45 endWithNewline()
Brian Silverman8fce7482020-01-05 13:18:21 -080046 }
Maxwell Henderson80bec322024-01-09 15:48:44 -080047 json {
48 target fileTree('.') {
49 include '**/*.json'
50 exclude '**/build/**', '**/build-*/**', '**/bin/**'
51 exclude '**/simgui-ds.json', '**/simgui-window.json', '**/simgui.json', '**/networktables.json'
Austin Schuh812d0d12021-11-04 20:16:48 -070052 }
Maxwell Henderson80bec322024-01-09 15:48:44 -080053 gson()
54 .indentWithSpaces(2)
Austin Schuh812d0d12021-11-04 20:16:48 -070055 }
Maxwell Henderson80bec322024-01-09 15:48:44 -080056 format 'xml', {
57 target fileTree('.') {
58 include '**/*.xml'
59 exclude '**/build/**', '**/build-*/**', '**/bin/**', '**/.idea/**', '**/.run/**'
60 }
61 eclipseWtp('xml')
62 trimTrailingWhitespace()
63 indentWithSpaces(2)
64 endWithNewline()
Austin Schuh812d0d12021-11-04 20:16:48 -070065 }
Maxwell Henderson80bec322024-01-09 15:48:44 -080066 format 'misc', {
67 target fileTree('.') {
68 include '**/*.md', '**/.gitignore'
69 exclude '**/build/**', '**/build-*/**', '**/bin/**'
70 }
71 trimTrailingWhitespace()
72 indentWithSpaces(2)
73 endWithNewline()
74 }
75}
76
77apply plugin: 'com.github.spotbugs'
78
79spotbugs {
80 ignoreFailures = false
81 effort = spotbugsEffort
82 excludeFilter = file("${project.rootDir}/styleguide/spotbugs-exclude.xml")
Brian Silverman8fce7482020-01-05 13:18:21 -080083}
Austin Schuh1e69f942020-11-14 15:06:14 -080084
85task javaFormat {
86 dependsOn(tasks.withType(Checkstyle))
87 dependsOn(tasks.withType(Pmd))
88}
Austin Schuh812d0d12021-11-04 20:16:48 -070089javaFormat.dependsOn 'spotlessApply'