Is there any way to actually debug a maven plugin while it is in action. What I mean is that for example we have the maven-clean-plugin. So when this plugin executes it's action can we somehow debug and check inside the source code of maven-clean-plugin?
Obviously we would have to associate the Java source for the plugin in eclipse but how can we set it for debugging?
Thanks.
EDIT: Changing the subject I'm sorry guys maybe I should have been more precise. Actually I have my web-app which is a maven project, which makes use of 3rd party maven plugins. Now when I do a mvn clean install I need to debug my 3rd party maven plugin. Now in my maven dependency I dont get a dependency to that plugin jar, which is quite normal. Any ideas?
To run Maven in debug mode, use the command mvnDebug instead of mvn to build your project and then attach to it using your IDE. Debug breakpoints should be hit. I've done this with Eclipse, mostly when trying to debug my own annotation processors, but it's also handy for debugging Maven plugins.
To view full stack traces, please go to the Settings->Maven and check the 'Print Exception Stack Traces' box.
If you start your build with mvnDebug clean install instead of mvn clean install Maven will wait for a remote debugger to connect on port 8000 . This should work for all plugin that to not run in their own JVM. This requires Maven greater than 2.0. 8 which I assume you are running.
If you are using Eclipse with the m2eclipse plugin, simply launch your build with Debug As... instead of Run as....
If you are not using m2eclipse, run mvnDebug
instead of mvn
(for Maven 2.0.8+) and attach a remote debugger on port 8000. For Maven 2.0.8<, add the remote debuggin options to the start script.
Of course, you need to import the sources of the plugin in your workspace.
If you want to debug Maven execution in eclipse, here is how I did it, with mostly command-line tools (no Eclipse plugin used) (may be off at some points, I haven't done that for 6 months):
mvndebug
in place of the mvn
command. Maven will begin launching and wait for an external debugger to appear on a TCP port before resuming. Note the port number.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With