I have a java program that is built using Maven and I need to enable the assert
keyword. Ideally, I'd want to enable assertions in the maven build command.
Maven compiles and builds the java code. Assertion errors come when you are actually running java code so with maven you can't do it this way
unless you are using maven plugin to launch java code, you would have to supply -ea
to jvm
exec:java
Pass -ea
to commandline argument
Surefire
if you meant for test execution then configure sure-fire plugin to pass -ea
to jvm
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<enableAssertions>true</enableAssertions>
</configuration>
</plugin>