Created
September 30, 2019 19:56
-
-
Save bdemers/0226dcbaa7e2da2dd12b77eca8293bf5 to your computer and use it in GitHub Desktop.
Maven Fail On Warning
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
# Tested on OS X (with a bunch of gnu utils installed) | |
function mvnwarn { | |
tmp_file=$(mktemp $TMPDIR/$(uuidgen).txt) | |
MAVEN_OPTS="-Djansi.force=true" mvn -Dstyle.color=always $@ | tee "${tmp_file}" | |
exit_code=${pipestatus[1]} | |
if [ $exit_code -ne 0 ]; then | |
return 1 | |
fi | |
result=$(grep "WARN" "${tmp_file}") | |
grep_exit_status=$? | |
if [ $grep_exit_status -eq 0 ]; then | |
echo "\n\u001b[1mWarnings Found:\u001b[0m" | |
echo $result | |
false | |
return | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment