Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 1 | if (!project.hasProperty('skipJavaFormat')) { |
| 2 | apply plugin: 'checkstyle' |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 3 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 4 | checkstyle { |
| 5 | toolVersion = "8.38" |
| 6 | configDirectory = file("${project.rootDir}/styleguide") |
| 7 | config = resources.text.fromFile(new File(configDirectory.get().getAsFile(), "checkstyle.xml")) |
| 8 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 9 | |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 10 | apply plugin: 'pmd' |
| 11 | |
| 12 | pmd { |
| 13 | toolVersion = '6.7.0' |
| 14 | consoleOutput = true |
| 15 | reportsDir = file("$project.buildDir/reports/pmd") |
| 16 | ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml")) |
| 17 | ruleSets = [] |
| 18 | } |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 19 | |
| 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 Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 72 | } |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 73 | |
| 74 | task javaFormat { |
| 75 | dependsOn(tasks.withType(Checkstyle)) |
| 76 | dependsOn(tasks.withType(Pmd)) |
| 77 | } |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 78 | javaFormat.dependsOn 'spotlessApply' |