Apparently we already have an issue for this: https://issues.apache.org/jira/browse/MNG-6065 (and I was already watching issue)
On Mon, Sep 30, 2019 at 4:50 PM Brian Demers <[email protected]> wrote: > I'd like to fail a build on any WARNINGs. Some plugins can do this > already e.g. the compiler plugin with `maven.compiler.failOnWarning`. I'm > looking for a more general solution. > > I tried to hack up an extension this morning to configure an extra log > listener, that seemed like a dead end, as you cannot modify the > SLF4J/MavenSimpleLogger (without messing with the Maven distribution). > > My _quick and dirty_ solution was to create a shell script wrapper > function: > > ``` > > # 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 > } > > ``` > > Does anyone have any other suggestions? Anything we can add to Maven > directly (i'd love a `--fail-on-warning` flag)? > > Going the Logger route seems a little hackie, but it does seem like the > most generic way to capture everything. We _could_ add some sort of hook > in MavenSimpleLogger, but at that point using a different SLF4J impl > _might_ be easier. > > Thoughts/ideas? > > Anyone else doing something to scan for warnings? (other than a `mvn > install | grep WARN`) > > -Brian >
