Skip to content

Instantly share code, notes, and snippets.

@bdemers
Created September 30, 2019 19:56
Show Gist options
  • Save bdemers/0226dcbaa7e2da2dd12b77eca8293bf5 to your computer and use it in GitHub Desktop.
Save bdemers/0226dcbaa7e2da2dd12b77eca8293bf5 to your computer and use it in GitHub Desktop.
Maven Fail On Warning
# 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