mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
This avoids issues where Checkstyle will error on line length by having Spotless run first and fix up line lengths before Checkstyle sees the files.
94 lines
2.4 KiB
Groovy
94 lines
2.4 KiB
Groovy
if (project.hasProperty('skipJavaFormat')) {
|
|
return;
|
|
}
|
|
|
|
apply plugin: 'checkstyle'
|
|
|
|
checkstyle {
|
|
toolVersion = "13.4.0"
|
|
configDirectory = file("${project.rootDir}/styleguide")
|
|
config = resources.text.fromFile(new File(configDirectory.get().getAsFile(), "checkstyle.xml"))
|
|
}
|
|
|
|
apply plugin: 'pmd'
|
|
|
|
pmd {
|
|
toolVersion = '7.23.0'
|
|
consoleOutput = true
|
|
reportsDir = file("$project.buildDir/reports/pmd")
|
|
ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml"))
|
|
ruleSets = []
|
|
}
|
|
|
|
apply plugin: 'com.diffplug.spotless'
|
|
|
|
spotless {
|
|
java {
|
|
target fileTree('.') {
|
|
include '**/*.java'
|
|
exclude '**/build/**', '**/build-*/**', '**/bin/**', "src/generated/**"
|
|
}
|
|
toggleOffOn()
|
|
googleJavaFormat()
|
|
removeUnusedImports()
|
|
trimTrailingWhitespace()
|
|
endWithNewline()
|
|
}
|
|
groovyGradle {
|
|
target fileTree('.') {
|
|
include '**/*.gradle'
|
|
exclude '**/build/**', '**/build-*/**', '**/bin/**'
|
|
}
|
|
greclipse()
|
|
leadingTabsToSpaces(4)
|
|
trimTrailingWhitespace()
|
|
endWithNewline()
|
|
}
|
|
json {
|
|
target fileTree('.') {
|
|
include '**/*.json'
|
|
exclude '**/build/**', '**/build-*/**', '**/bin/**'
|
|
exclude '**/simgui-ds.json', '**/simgui-window.json', '**/simgui.json', '**/networktables.json', '**/*test.json'
|
|
}
|
|
gson()
|
|
.indentWithSpaces(2)
|
|
}
|
|
format 'xml', {
|
|
target fileTree('.') {
|
|
include '**/*.xml'
|
|
exclude '**/build/**', '**/build-*/**', '**/bin/**', '**/.idea/**', '**/.run/**'
|
|
}
|
|
eclipseWtp('xml')
|
|
trimTrailingWhitespace()
|
|
leadingTabsToSpaces(2)
|
|
endWithNewline()
|
|
}
|
|
format 'misc', {
|
|
target fileTree('.') {
|
|
include '**/*.md', '**/.gitignore'
|
|
exclude '**/build/**', '**/build-*/**', '**/bin/**'
|
|
}
|
|
trimTrailingWhitespace()
|
|
leadingTabsToSpaces(2)
|
|
endWithNewline()
|
|
}
|
|
}
|
|
|
|
apply plugin: 'com.github.spotbugs'
|
|
|
|
spotbugs {
|
|
ignoreFailures = false
|
|
effort = spotbugsEffort
|
|
excludeFilter = file("${project.rootDir}/styleguide/spotbugs-exclude.xml")
|
|
}
|
|
|
|
task javaFormat {
|
|
dependsOn(tasks.withType(Checkstyle))
|
|
dependsOn(tasks.withType(Pmd))
|
|
dependsOn 'spotlessApply'
|
|
}
|
|
|
|
tasks.withType(Checkstyle) {
|
|
it.mustRunAfter 'spotlessApply'
|
|
}
|