maven-plugin test
Answered
Is there a way to test and/or debug a maven-plugin in Intellji?
I am developing a maven plugin by extending
org.apache.maven.plugin.AbstractMojo
And implementing execute method
@Override
public void execute() throws MojoExecutionException, MojoFailureException
But do I start a test in Intellji and be able to debug it?
Please sign in to leave a comment.
>But do I start a test in Intellji and be able to debug it?
How do you start (what do you use to start it) the test and what code does it execute - the code you need to debug?
I could only create the plugin and test it from another project.
For simplicity, just follow the guide below to create a maven plugin
Maven – Guide to Developing Java Plugins (apache.org)
If you want to debug the source code which is executed by the plugin's goal - launch this Maven goal with the debug JVM options (for example for JDK9+ versions this VM options can be used:
and then launch the Remote JVM Debug run configuration that would attach the debugger to this launched JVM.
See https://stackoverflow.com/a/50330956/2000323
Andrey, yes you can find this remote debugging way everywhere on Stackoverflow.
But what'ts the use case for this feature then? https://www.jetbrains.com/help/idea/work-with-maven-goals.html#debug_goal
>But what'ts the use case for this feature then? https://www.jetbrains.com/help/idea/work-with-maven-goals.html#debug_goal
Indeed this action will launch the debug process for the Maven goal itself. But please note that unfortunately it will not be possible to debug tests with it.