buildscript { repositories repos dependencies { classpath "com.diffplug.spotless:spotless-plugin-gradle:3.24.3" } } apply plugin: com.diffplug.gradle.spotless.SpotlessPlugin spotless { java { target fileTree(projectDir) { include '**/*.java' } googleJavaFormat() } format 'misc', { target fileTree(projectDir) { include '**/.gitignore' include '**/*.gradle' include '**/*.adoc' include '**/*.sh' include '**/*.html' include '**/*.js' include '**/*.css' include '**/*.xml' include '**/*.xsd' exclude '**/webapp/lib/*' exclude '**/webapp/dist/*' exclude '**/webapp/node_modules/*' } indentWithSpaces(2) trimTrailingWhitespace() endWithNewline() } format 'markdown', { target '**/*.md' indentWithSpaces(2) endWithNewline() } } task formatCode(dependsOn: ['licenseFormat', 'spotlessApply']) build.dependsOn 'spotlessApply'