Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug a maven plugin's execution in a maven web-project

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?

like image 849
user320550 Avatar asked Jun 04 '10 12:06

user320550


People also ask

How do I debug a Maven error?

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.

How do you see the full stack trace of the errors re run Maven with the switch?

To view full stack traces, please go to the Settings->Maven and check the 'Print Exception Stack Traces' box.

How do I debug a custom Maven plugin?

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.


2 Answers

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.

See also

  • Developing and debugging Maven plugins
  • Dealing with Eclipse-based IDE
like image 86
Pascal Thivent Avatar answered Sep 28 '22 03:09

Pascal Thivent


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):

  • Run, from the command line, 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.
  • Configure in Eclipse a custom, remote debug configuration. (See http://www.ibm.com/developerworks/library/os-ecbug/ , Remote debugging) - set the port number as the one used by mvndebug. Also put the source files that you will be using for debugging in the Debug configuration.
  • Launch the remote debug configuration. Maven should resume and you will catch bugs in Eclipse.
like image 20
Jean Hominal Avatar answered Sep 28 '22 02:09

Jean Hominal