Created
August 7, 2018 01:54
-
-
Save willmenn/8034c3a9cc39dcbcfce42bbfceeab9b6 to your computer and use it in GitHub Desktop.
Gradle Checkstyle with threshold of errors.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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