MavenHelper icon indicating copy to clipboard operation
MavenHelper copied to clipboard

[FEATURE REQUEST] Command to build selected module with all required modules

Open szymex opened this issue 10 years ago • 16 comments

Command to build selected module with all required modules. For example:

mvn install -pl module-abc -am

szymex avatar Aug 16 '15 18:08 szymex

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'.

jeacott1 avatar Mar 03 '22 08:03 jeacott1

Is $moduleName$ all that is needed? If so, then you can try it: MavenRunHelper.zip

krasa avatar Mar 03 '22 08:03 krasa

@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

jeacott1 avatar Mar 03 '22 08:03 jeacott1

@krasa - tried the file you provided above - seems broken now. - in the cmd generated it now says -Dtest=NOT_RESOLVED :(

jeacott1 avatar Mar 03 '22 08:03 jeacott1

Fixed: MavenRunHelper.zip

resolve-workspace-artifacts settings is here, it should now work for tests too: image

krasa avatar Mar 03 '22 08:03 krasa

@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?

jeacott1 avatar Mar 03 '22 09:03 jeacott1

"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 avatar Mar 03 '22 09:03 krasa

@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.

jeacott1 avatar Mar 03 '22 09:03 jeacott1

$classWithMethod$ requires a caret in the method.

krasa avatar Mar 03 '22 10:03 krasa

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 avatar Mar 03 '22 10:03 krasa

@krasa yep - cursor/caret in the method - no method in result

image image

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)

jeacott1 avatar Mar 03 '22 10:03 jeacott1

Is the method executable by IntelliJ itself? image

krasa avatar Mar 03 '22 10:03 krasa

@krasa no, and I have no idea how to make it so. I guess thats the reason.

jeacott1 avatar Mar 03 '22 10:03 jeacott1

It needs a JUnit dependency and the annotation, or some alternative.

krasa avatar Mar 03 '22 10:03 krasa

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.

jeacott1 avatar Mar 03 '22 10:03 jeacott1

you could try intellij support, it should just work, if the maven setup is correct and JUnit plugin is enabled

krasa avatar Mar 03 '22 10:03 krasa