apply plugin: 'checkstyle' dependencies { checkstyle 'com.puppycrawl.tools:checkstyle:8.0' } def checkstyleConfigDir = new File(buildscript.sourceFile.parentFile, 'enforcement') checkstyle { configFile = new File(checkstyleConfigDir, "checkstyle.xml") configProperties.checkstyleConfigDir = checkstyleConfigDir maxWarnings = 500 } plugins.withType(GroovyBasePlugin) { sourceSets.all { sourceSet -> tasks.register("${sourceSet.getTaskName('checkstyle', 'groovy')}", Checkstyle) { configFile = new File(checkstyleConfigDir, "checkstyle-groovy.xml") source sourceSet.allGroovy classpath = sourceSet.compileClasspath reports.xml.destination new File(checkstyle.reportsDir, "${sourceSet.name}-groovy.xml") } } } def checkstyleTasks = tasks.withType(Checkstyle) tasks.register("checkstyle") { dependsOn checkstyleTasks } check.dependsOn checkstyleTasks tasks.withType(Test).configureEach { mustRunAfter checkstyleTasks } // Verification seems broken on Java 9. apply plugin: 'com.github.sherter.google-java-format' googleJavaFormat { source = sourceSets*.allJava exclude '**/build/**/*.java' } tasks.withType(Checkstyle).configureEach { mustRunAfter verifyGoogleJavaFormat }