How to configure a mvn -am -pl <module> <goal> in Run config?

Hello,

I've a project which consists of 3 sub modules, like this:

/project/web
-- commons
-- entites
-- services

The dependency between is pretty simple, entities depends on commons; and services depends on entities and commons. When I want to compile and package the services I need to manually execute the install goal on commons and entities before packing the services module. This is how I currently do.

I've found a maven command that simplifies this process but I don't know how to configure IDEA to run the command:

$ cd /project/web
$ mvn -am -pl services install

$ mvn -am -pl vc-services install
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO]   web
[INFO]   commons
[INFO]   entities
[INFO]   services
...

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] web ................................................ SUCCESS [3.687s]
[INFO] commons ............................................ SUCCESS [2.916s]
[INFO] entities ........................................... SUCCESS [6.102s]
[INFO] services ........................................... SUCCESS [0.330s]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL



When I execute this maven automatically find the modules that services depends on and execute the install goal before execute install on services. How could I do this inside IDEA?
3 comments
Comment actions Permalink

Do your sub modules inherit from a parent pom?  If they do you can add your sub modules to the <modules> section of the parent pom and just run a "mvn install" at the parent pom level and it will build/install all the modules in the correct order without having to do it manually.

0
Comment actions Permalink

Hi Russ, yes it works for my current project.

But, my concern asking this is because this option only execute the goal on the direct dependencies instead of all. I think it would be a good option to have in IDEA.

0
Comment actions Permalink

I've found an alternative way that works just like -am -pl (which I don't know exactly what it mean), let's suppose our project web has another module called war:

/project/web
-- commons
-- entites
-- services
-- war



And we want to install on local repository only commons, entities and services; this will be possible to execute mvn package on the war. I don't want to install a war, so to this just execute:

mvn reactor:make -Dmake.folders=services
0

Please sign in to leave a comment.