MavenHelper
MavenHelper copied to clipboard
[FEATURE REQUEST] Command to build selected module with all required modules
Command to build selected module with all required modules. For example:
mvn install -pl module-abc -am
this is definitely required - its currently impossible to run individual tests in multi module projects with this as-is. this plugin also seems to completely ignore any use or 'resolve-workspace-artifacts'.
Is $moduleName$ all that is needed? If so, then you can try it: MavenRunHelper.zip
@krasa actually had a brief look at the code - I think all thats really needed is in the test actions, hunt for the ''resolve-workspace-artifacts' boolean setting, and if it exists add -am to the maven cmd options. if there was a place to do it in intellij I'd suggest a means to properly customise the maven options, but for my purposes all I actually want is to set the root folder (module), and pass -am
@krasa - tried the file you provided above - seems broken now. - in the cmd generated it now says -Dtest=NOT_RESOLVED :(
Fixed: MavenRunHelper.zip
resolve-workspace-artifacts settings is here, it should now work for tests too:

@krasa thanks, better! there might be a bug in that whenever I edit the settings I need to restart the ide or the plugin context menus are completely gone.
ok, I got what I wanted working - but I also needed to add -f /path/to/my/aggregator-root/weirdnamedpom.xml thank you! - I don't much like intellij but this makes dealing with it soooo much better,
the only thing I couldn't find was a variable or some means to find the project root folder or a specific module folder - the line above finds the absolute path, which works. is there a way?
"there might be a bug in that whenever I edit the settings I need to restart the ide or the plugin context menus are completely gone."
That sounds super strange, is there something in the log?
So you want a macro for a maven root project folder? That should be no problem.
@krasa I'll get back to you on that - havent had it happen again in a while.
fyi my previous settings didn't quite work.
I tried adding a -Dmaven.multiModuleProjectDirectory=/path/to/my/aggregator-root but unfortunately it doesn't override the default one so I cant test other modules except the root module.
I also added -f weirdaggpom.xml -Dit.test=$classWithMethod$
$classWithMethod$ is only giving me the classname. I had hoped it might generate className#testMethodName - should it?
fyi, in my case my parent pom is strictly an aggregator. there is no parent set to this pom in any of the submodules.
$classWithMethod$ requires a caret in the method.
Dmaven.multiModuleProjectDirectory and -f pomname is set here (mavenProject.getDirectory(), null), so it could be customized somehow:
https://github.com/krasa/MavenHelper/blob/1309372be0c0752328f51105e945d0d95867f187/src/main/java/krasa/mavenhelper/action/RunTestFileAction.java#L51
@krasa yep - cursor/caret in the method - no method in result

I will note that intellij cant resolve various dependencies in this project (maven can, maven in intellij can, and in this particular module (same folder as the root pom - maven helper can build and run this test - it just doesnt give me the #test)
Is the method executable by IntelliJ itself?

@krasa no, and I have no idea how to make it so. I guess thats the reason.
It needs a JUnit dependency and the annotation, or some alternative.
yeah - and for whatever reason, it cant find junit despite the maven config. thanks for the hints. I'll play.
re the maven.multiModuleProjectDirectory - the built in maven plugin has a 'working directory' setting which I think is probably the same thing.
you could try intellij support, it should just work, if the maven setup is correct and JUnit plugin is enabled