Files
allwpilib/shared/java/javastyle.gradle

87 lines
2.4 KiB
Groovy
Raw Normal View History

if (!project.hasProperty('skipJavaFormat')) {
apply plugin: 'checkstyle'
2018-06-03 10:00:53 -07:00
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
apply plugin: 'pmd'
pmd {
toolVersion = '6.55.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/**'
}
toggleOffOn()
googleJavaFormat()
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
groovyGradle {
target fileTree('.') {
include '**/*.gradle'
exclude '**/build/**', '**/build-*/**', '**/bin/**'
}
greclipse()
indentWithSpaces(4)
trimTrailingWhitespace()
endWithNewline()
}
2023-01-16 18:26:46 +02:00
json {
target fileTree('.') {
include '**/*.json'
exclude '**/build/**', '**/build-*/**', '**/bin/**'
2023-01-16 18:26:46 +02:00
}
gson()
.indentWithSpaces(2)
}
format 'xml', {
target fileTree('.') {
include '**/*.xml'
exclude '**/build/**', '**/build-*/**', '**/bin/**'
}
eclipseWtp('xml')
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
format 'misc', {
target fileTree('.') {
include '**/*.md', '**/.gitignore'
exclude '**/build/**', '**/build-*/**', '**/bin/**'
}
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
}
apply plugin: 'com.github.spotbugs'
spotbugs {
ignoreFailures = false
effort = 'max'
excludeFilter = file("${project.rootDir}/styleguide/spotbugs-exclude.xml")
}
2018-06-03 10:00:53 -07:00
}
task javaFormat {
dependsOn(tasks.withType(Checkstyle))
dependsOn(tasks.withType(Pmd))
}
javaFormat.dependsOn 'spotlessApply'