FaqDebugMojo
Can I debug Maven builds (mojo code) from the IDE?
Yes. The following steps were tested with a NB 7.0 development build but ought to apply to earlier releases as well.
I made a "Java Application" and added
<build> <plugins> <plugin> <groupId>org.codehaus.mojo.webstart</groupId> <artifactId>webstart-maven-plugin</artifactId> <version>1.0-beta-1</version> </plugin> </plugins> </build>
In the properties dialog of the demo project, I added a custom action to run a sample mojo while debugging the build, so that my nbactions.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?> <actions> <action> <actionName>CUSTOM-debug-mojo</actionName> <displayName>Debug Mojo</displayName> <goals> <goal>-e</goal> <goal>package</goal> <goal>webstart:jnlp-inline</goal> </goals> <properties> <jpda.listen>maven</jpda.listen> </properties> </action> </actions>
(You can also run the same goals without creating a custom action, if you don't mind retyping the above information each time.) As expected (given that I have configured nothing related to JNLP in this project), it fails with a stack trace:
java.lang.NullPointerException at org.codehaus.mojo.webstart.AbstractJnlpMojo.execute(AbstractJnlpMojo.java:214)
If I check out https://svn.codehaus.org/mojo/tags/webstart-1.0-beta-1/webstart-maven-plugin and open it in the IDE, and set a breakpoint on that line, then when running the custom action the debugger stops at that line and shows me that jnlp = null.