2023-12-09 15:34:29 -08:00
|
|
|
if (project.hasProperty('skipJavaFormat')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-06-03 10:00:53 -07:00
|
|
|
|
2023-12-09 15:34:29 -08:00
|
|
|
apply plugin: 'checkstyle'
|
|
|
|
|
|
|
|
|
|
checkstyle {
|
|
|
|
|
toolVersion = "10.12.2"
|
|
|
|
|
configDirectory = file("${project.rootDir}/styleguide")
|
|
|
|
|
config = resources.text.fromFile(new File(configDirectory.get().getAsFile(), "checkstyle.xml"))
|
|
|
|
|
}
|
2018-06-03 10:00:53 -07:00
|
|
|
|
2023-12-09 15:34:29 -08:00
|
|
|
apply plugin: 'pmd'
|
2019-06-28 14:09:10 -07:00
|
|
|
|
2023-12-09 15:34:29 -08:00
|
|
|
pmd {
|
2024-06-09 01:08:23 -04:00
|
|
|
toolVersion = '7.2.0'
|
2023-12-09 15:34:29 -08:00
|
|
|
consoleOutput = true
|
|
|
|
|
reportsDir = file("$project.buildDir/reports/pmd")
|
|
|
|
|
ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml"))
|
|
|
|
|
ruleSets = []
|
|
|
|
|
}
|
2021-09-24 16:04:02 -07:00
|
|
|
|
2023-12-09 15:34:29 -08:00
|
|
|
apply plugin: 'com.diffplug.spotless'
|
2021-09-24 16:04:02 -07:00
|
|
|
|
2023-12-09 15:34:29 -08:00
|
|
|
spotless {
|
|
|
|
|
java {
|
|
|
|
|
target fileTree('.') {
|
|
|
|
|
include '**/*.java'
|
|
|
|
|
exclude '**/build/**', '**/build-*/**', '**/bin/**', "src/generated/**"
|
2021-09-24 16:04:02 -07:00
|
|
|
}
|
2023-12-09 15:34:29 -08:00
|
|
|
toggleOffOn()
|
|
|
|
|
googleJavaFormat()
|
|
|
|
|
removeUnusedImports()
|
|
|
|
|
trimTrailingWhitespace()
|
|
|
|
|
endWithNewline()
|
|
|
|
|
}
|
|
|
|
|
groovyGradle {
|
|
|
|
|
target fileTree('.') {
|
|
|
|
|
include '**/*.gradle'
|
|
|
|
|
exclude '**/build/**', '**/build-*/**', '**/bin/**'
|
2021-09-24 16:04:02 -07:00
|
|
|
}
|
2023-12-09 15:34:29 -08:00
|
|
|
greclipse()
|
|
|
|
|
indentWithSpaces(4)
|
|
|
|
|
trimTrailingWhitespace()
|
|
|
|
|
endWithNewline()
|
|
|
|
|
}
|
|
|
|
|
json {
|
|
|
|
|
target fileTree('.') {
|
|
|
|
|
include '**/*.json'
|
|
|
|
|
exclude '**/build/**', '**/build-*/**', '**/bin/**'
|
|
|
|
|
exclude '**/simgui-ds.json', '**/simgui-window.json', '**/simgui.json', '**/networktables.json'
|
2023-01-16 18:26:46 +02:00
|
|
|
}
|
2023-12-09 15:34:29 -08:00
|
|
|
gson()
|
|
|
|
|
.indentWithSpaces(2)
|
|
|
|
|
}
|
|
|
|
|
format 'xml', {
|
|
|
|
|
target fileTree('.') {
|
|
|
|
|
include '**/*.xml'
|
|
|
|
|
exclude '**/build/**', '**/build-*/**', '**/bin/**', '**/.idea/**', '**/.run/**'
|
2021-09-24 16:04:02 -07:00
|
|
|
}
|
2023-12-09 15:34:29 -08:00
|
|
|
eclipseWtp('xml')
|
|
|
|
|
trimTrailingWhitespace()
|
|
|
|
|
indentWithSpaces(2)
|
|
|
|
|
endWithNewline()
|
|
|
|
|
}
|
|
|
|
|
format 'misc', {
|
|
|
|
|
target fileTree('.') {
|
|
|
|
|
include '**/*.md', '**/.gitignore'
|
|
|
|
|
exclude '**/build/**', '**/build-*/**', '**/bin/**'
|
2021-09-24 16:04:02 -07:00
|
|
|
}
|
2023-12-09 15:34:29 -08:00
|
|
|
trimTrailingWhitespace()
|
|
|
|
|
indentWithSpaces(2)
|
|
|
|
|
endWithNewline()
|
2021-09-24 16:04:02 -07:00
|
|
|
}
|
2023-12-09 15:34:29 -08:00
|
|
|
}
|
2021-09-24 16:04:02 -07:00
|
|
|
|
2023-12-09 15:34:29 -08:00
|
|
|
apply plugin: 'com.github.spotbugs'
|
2021-09-24 16:04:02 -07:00
|
|
|
|
2023-12-09 15:34:29 -08:00
|
|
|
spotbugs {
|
|
|
|
|
ignoreFailures = false
|
|
|
|
|
effort = spotbugsEffort
|
|
|
|
|
excludeFilter = file("${project.rootDir}/styleguide/spotbugs-exclude.xml")
|
2018-06-03 10:00:53 -07:00
|
|
|
}
|
2020-10-24 23:18:19 -04:00
|
|
|
|
|
|
|
|
task javaFormat {
|
|
|
|
|
dependsOn(tasks.withType(Checkstyle))
|
|
|
|
|
dependsOn(tasks.withType(Pmd))
|
|
|
|
|
}
|
2021-09-24 16:04:02 -07:00
|
|
|
javaFormat.dependsOn 'spotlessApply'
|