Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Enable Java assertions in Maven for Tomcat and Jetty

DZone's Guide to

Enable Java assertions in Maven for Tomcat and Jetty

· Java Zone
Free Resource

Navigate the Maze of the End-User Experience and pick up this APM Essential guide, brought to you in partnership with CA Technologies

I wanted to enable assertions while running Jetty and Tomcat plugin’s with Maven and have not found any postings talking about how to enable assertions other than with surefire unit tests, and with a custom eclipse or intellij IDEA runner.

So what about on the command line?

Java assertions are enabled by the following syntax:

--ea[:...|:] or enableassertions  (to enable assertion at a particular package and class level)

But how can I enable them for the Tomcat Maven plugin?

I had tried the following options with no success:

export JAVA_OPTS="-ea"
export JAVA_ARGS="-ea"
export CATALINA_OPTS="-ea"
...
export JAVA_OPTS="-enableassertions"
export JAVA_ARGS="-enableassertions"
export CATALINA_OPTS="-enableassertions"

But the solution for adding MAVEN_OPTS as depicted:

export MAVEN_OPTS="-ea"
... or ...
export MAVEN_OPTS="-enableassertions"

Hopefully this can help other to use more assertions.


Thrive in the application economy with an APM model that is strategic. Be E.P.I.C. with CA APM.  Brought to you in partnership with CA Technologies.

Topics:

Published at DZone with permission of Mick Knutson, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}