opentelemetry-java-instrume.../gradle/checkstyle.gradle

37 lines
934 B
Groovy

apply plugin: 'checkstyle'
dependencies {
checkstyle 'com.puppycrawl.tools:checkstyle:8.20'
}
def checkstyleConfigDir = file("${buildscript.sourceFile.parentFile}/enforcement/checkstyle")
checkstyle {
configDir = checkstyleConfigDir
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(allGroovy)
classpath = sourceSet.compileClasspath
reports.xml.destination = new File(reportsDir, "${sourceSet.name}-groovy.xml")
}
}
}
def checkstyleTasks = tasks.withType(Checkstyle)
tasks.register("checkstyle") {
dependsOn checkstyleTasks
}
check.dependsOn checkstyleTasks
tasks.withType(Test).configureEach {
mustRunAfter checkstyleTasks
}