How to fail a maven build when jacoco bytecode instrumentation has an error

42 Views Asked by At

I'm using the jacoco-maven-plugin with the goal prepare-agent to measure the test coverage. From my understanding, the goal simply sets the argLine property to point to an javaagent and when the maven-surefire-plugin executes the tests, it picks up the argLine property, so the executed java classes are bytecode instrumented on the fly. As a result I get a jacoco.exec file which contains the necessary information to calculate the test coverage. When the bytecode instrumentation fails (e.g. when the compiled java class is very large and the size of one method is just a bit below the 32KB limit and the bytecode instrumentation would push the size above the 32KB limit or when I'm using version 0.8.5 of the jacoco-maven-plugin with java version 17), I see some log messages stating the error but the maven build continues. So my question is: Is there any possibility to fail the maven build if the bytecode instrumentation during the execution of the maven-surefire-plugin produces any error message?

Neither in the documentation for the jacoco-maven-plugin nor for the maven-surefire-plugin I could find any parameter to fail the maven build.

0

There are 0 best solutions below