Debugging Maven

When developing with maven by default there is no way to debug maven – or a self written maven plugin. This is really nasty when trying to write a plugin and then test the plugin. But there is a simple solution/workaround to do this.

Maven or a Maven Plugin

In order to debug maven or a plugin simply set the environment variable MAVEN_OPTS to the following value:

Then the process opens port 8000 and you are able to all the cool stuff when connecting with a debugger! Setting the option suspend=y helps debugging a lot because it requires the jvm to wait until a debugger is connected. But be careful! Without removing the option maven always will wait for a debugger to be connected.

This helps debugging maven or a maven plugin. But this is not a good idea when debugging a test that runs with the maven surefire plugin.

Tests or Integration Tests

For debugging a test you can add the following option when running maven. Choose the first option to run normal unit tests in debug mode. The second option helps debugging integration tests.


Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.