Skip to content

Instantly share code, notes, and snippets.

@willmenn
Created August 7, 2018 01:54
Show Gist options
  • Save willmenn/8034c3a9cc39dcbcfce42bbfceeab9b6 to your computer and use it in GitHub Desktop.
Save willmenn/8034c3a9cc39dcbcfce42bbfceeab9b6 to your computer and use it in GitHub Desktop.
Gradle Checkstyle with threshold of errors.
tasks.withType(Checkstyle).each { checkstyleTask ->
checkstyleTask.doLast {
reports.all { report ->
def errors = 0
def threshold = 1
def outputFile = report.destination
outputFile.text.eachLine {
if (it.contains("<error ")) {
errors++
}
}
if(errors >= threshold){
throw new GradleException("There were checkstyle warnings! For more info check $outputFile")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment