mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
This also makes the Gradle build work with JDK 17. The extra JVM args in gradle.properties works around a bug with spotless and JDK 17: https://github.com/diffplug/spotless/issues/834 PMD.CloseResource was ignored because it's almost always a false positive, and there are many of them.
79 lines
2.1 KiB
Groovy
79 lines
2.1 KiB
Groovy
if (!project.hasProperty('skipJavaFormat')) {
|
|
apply plugin: 'checkstyle'
|
|
|
|
checkstyle {
|
|
toolVersion = "9.2"
|
|
configDirectory = file("${project.rootDir}/styleguide")
|
|
config = resources.text.fromFile(new File(configDirectory.get().getAsFile(), "checkstyle.xml"))
|
|
}
|
|
|
|
apply plugin: 'pmd'
|
|
|
|
pmd {
|
|
toolVersion = '6.41.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-*/**'
|
|
}
|
|
toggleOffOn()
|
|
googleJavaFormat()
|
|
removeUnusedImports()
|
|
trimTrailingWhitespace()
|
|
endWithNewline()
|
|
}
|
|
groovyGradle {
|
|
target fileTree('.') {
|
|
include '**/*.gradle'
|
|
exclude '**/build/**', '**/build-*/**'
|
|
}
|
|
greclipse()
|
|
indentWithSpaces(4)
|
|
trimTrailingWhitespace()
|
|
endWithNewline()
|
|
}
|
|
format 'xml', {
|
|
target fileTree('.') {
|
|
include '**/*.xml'
|
|
exclude '**/build/**', '**/build-*/**'
|
|
}
|
|
eclipseWtp('xml')
|
|
trimTrailingWhitespace()
|
|
indentWithSpaces(2)
|
|
endWithNewline()
|
|
}
|
|
format 'misc', {
|
|
target fileTree('.') {
|
|
include '**/*.md', '**/.gitignore'
|
|
exclude '**/build/**', '**/build-*/**'
|
|
}
|
|
trimTrailingWhitespace()
|
|
indentWithSpaces(2)
|
|
endWithNewline()
|
|
}
|
|
}
|
|
|
|
apply plugin: 'com.github.spotbugs'
|
|
|
|
spotbugs {
|
|
ignoreFailures = false
|
|
effort = 'max'
|
|
excludeFilter = file("${project.rootDir}/styleguide/spotbugs-exclude.xml")
|
|
}
|
|
}
|
|
|
|
task javaFormat {
|
|
dependsOn(tasks.withType(Checkstyle))
|
|
dependsOn(tasks.withType(Pmd))
|
|
}
|
|
javaFormat.dependsOn 'spotlessApply'
|