How to enable assertions in jetty-maven-plugin? By default they are disabled.
Set environment variable MAVEN_OPTS
to -ea
. Jetty by default runs within Maven process and thus is affected by this setting.
There is also interesting library called Force Assertions which hooks into Java 1.6 compilation process. During compilation all assert cond : detail;
are transparently compiled to if (!cond) throw new Assertion(detail);
blocks, which means assertions will work always no matter what JVM parameters are. Worth to check.