Search code examples
intellij-idea

How to debug a maven goal with intellij idea?


Can you debug a maven goal with Intellij IDEA? I know that I can right-click and run Debug. However, the maven plugin does not appear in my External Libraries list, so I can not go into the code and set a breakpoint. Thus, Debug runs through the goals without stopping, like Run does.

I am using OS X 10.8 and IDEA 12.0.2.

EDIT: Goal

I've written custom specRunner for https://github.com/searls/jasmine-maven-plugin - However, $specs$ stays empty. So I try to see which files are actually loaded.


Solution

  • Figured it out:

    • from the command line, run maven goal with mvnDebug instead of mvn. 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.
      1. Under Settings set:
        • Transport: Socket
        • Debugger Mode: Attach
        • Host: localhost
        • Port: 8000 (default port of mvnDebug)
    1. Run the Configuration in Debug mode. It should connect to the waiting mvnDebug jvm.