blob: ffe344c3a6b900ffea27c28f89ccb3d06d4844ad [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 {
Austin Schuh75263e32022-02-22 18:05:32 -08005 toolVersion = "9.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 {
Austin Schuh75263e32022-02-22 18:05:32 -080013 toolVersion = '6.41.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'
26 exclude '**/build/**', '**/build-*/**'
27 }
28 toggleOffOn()
29 googleJavaFormat()
30 removeUnusedImports()
31 trimTrailingWhitespace()
32 endWithNewline()
33 }
34 groovyGradle {
35 target fileTree('.') {
36 include '**/*.gradle'
37 exclude '**/build/**', '**/build-*/**'
38 }
39 greclipse()
40 indentWithSpaces(4)
41 trimTrailingWhitespace()
42 endWithNewline()
43 }
44 format 'xml', {
45 target fileTree('.') {
46 include '**/*.xml'
47 exclude '**/build/**', '**/build-*/**'
48 }
49 eclipseWtp('xml')
50 trimTrailingWhitespace()
51 indentWithSpaces(2)
52 endWithNewline()
53 }
54 format 'misc', {
55 target fileTree('.') {
56 include '**/*.md', '**/.gitignore'
57 exclude '**/build/**', '**/build-*/**'
58 }
59 trimTrailingWhitespace()
60 indentWithSpaces(2)
61 endWithNewline()
62 }
63 }
64
65 apply plugin: 'com.github.spotbugs'
66
67 spotbugs {
68 ignoreFailures = false
69 effort = 'max'
70 excludeFilter = file("${project.rootDir}/styleguide/spotbugs-exclude.xml")
71 }
Brian Silverman8fce7482020-01-05 13:18:21 -080072}
Austin Schuh1e69f942020-11-14 15:06:14 -080073
74task javaFormat {
75 dependsOn(tasks.withType(Checkstyle))
76 dependsOn(tasks.withType(Pmd))
77}
Austin Schuh812d0d12021-11-04 20:16:48 -070078javaFormat.dependsOn 'spotlessApply'