How to debug a maven goal with intellij idea?
Solution 1:
Figured it out:
- from the command line, run maven goal with
mvnDebug
instead ofmvn
. E.g.mvnDebug clean
- Open the source of the maven plugin you want to debug in intelliJ and set a breakPoint
- In IDEA, add a
Remote JVM Debug
Configuration.- Under Settings, set Transport: Socket, Debugger Mode: Attach, Host: localhost, Port: 8000 (default port of mvnDebug).
- Run the Configuration in Debug mode. It should connect to the waiting mvnDebug jvm.
Solution 2:
Very easy. I am using Intellj Idea 15.0.4
- Set the breakpoint in your maven plugin
- In the tag "Maven Projects" go to the project witch is using your maven plugin.
- In "Plugins" find your plugin and over the goal right click and Debug
Here is a screenshot:
Solution 3:
Old question, but I was having the same need and it took me a while to get it to work. Hopefully can help someone.
For test debugging use:
mvn <goal> -Dmaven.surefire.debug
or
mvn <goal> -Dmaven.failsafe.debug
When execution stops and listens to socket at address 5005 (default) you run your configured remote debugger.
How to configure it:
Run -> Edit configurations -> Remote Transport: socket Debugger mode: Attach Port: 5005 (default)
-> Save.
Solution 4:
The easiest way to debug maven goal ONLY within IntelliJ is to create a regular maven goal and in the runner tab pass those VM options:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
Where 8000 is a port number for remote debugging.
Then create new Remote configuration with port 8000. Run this configuration after running maven goal.
Solution 5:
I think the easiest solution is to temporarily add the maven plugin as a dependency. Once this is done, IntelliJ will treat this just like any other dependency and you can set breakpoints the usual way.