maven plugin extensions
已回答
Hello,
it looks like extensions bundled with Maven plugins (like this https://maven.apache.org/guides/mini/guide-using-extensions.html#plug-ins-which-provide-lifecycle-enhancements) are currently ignored when e.g. launching tests from the IDE. I was wondering whether that's on purpose or a bug.
Thanks.
请先登录再写评论。
Can you please add a bit more details to the problem: what actions to you take and what is expected/actual result you get? What extension do you use? It would very help to get a sample project. For uploading you can use https://uploads.jetbrains.com or any file sharing service. Thank you.
Sure. I am including an implementation of org.apache.maven.AbstractMavenLifecycleParticipant` in my maven plugin and implementing its afterProjectsRead(MavenSession) method. The Maven plugin is configured with `<extensions>true<extensions>` in the application project.
In `afterProjectsRead(session)` I'm checking the surefire/failsafe maven plugin configs (of the project modules that also include my plugin) to make sure the required properties are present and if they aren't present I am actually adding them. Nothing really special, just maven home dir, local maven repo path, etc. Because these properties aren't propagated to the tests by default.
So, when I run the tests from the command line with `mvn test`, it works. But the IDE isn't calling my lifecycle participant impl. I know it's possible to add the test config for my app in the IDE but the whole point of the plugin in this case is to not require users of my Maven plugin do that explicitly.
This may not be supported and could be another case similar to https://youtrack.jetbrains.com/issue/IDEA-158111
Please try Generate Sources and Update Folders action in Maven tool window. If it does not work, it would be great if you create an issue at https://youtrack.jetbrains.com/issues/IDEA with a self contains sample project or the exact information that could be used to reproduce this case. Thank you!
Right, the issues are similar. I am getting an impression it's not considered to be a bug. If that's the case, is there an IDEA API (something like m2e in eclipse) that could be used to hook into the project init and/or lifecycle participation or a plan to introduce that? The idea is to avoid users configure the IDE explicitly (e.g. by installing IDE plugins and/or creating project test configs, etc). Thanks!
Thank you for the details.
By default, IDEA does not call Maven to build sources or run tests. So it is expected that extensions are not called in these moments.
During import, IDEA should better respect the extensions, but currently there is no way to configure additional parameters for IDEA's junit/testng run configurations.
If a user calls Maven's test task from Maven toolwindow UI, the plugin should work just fine, but test console will be missing.