BoomRamada BoomRamada - 1 year ago 89
Java Question

Maven install in modular project

I got a multi level maven project as follows;

Core (generate core jar)
web-service (generate service jar)
web-app(generate WAR)

In Parent POM, I have define the modules as core,web-service and web-app.

In web-app module, I have dependencies for core.jar and service.jar.

Is there is a way to generate the war file in web-app through parent?
When I try to run mvn install in web-app. I get dependency issue with core.jar and web-service jar. which mean. I have to run mvn install in parent project first then run the mvn war:war in web-app project?

Answer Source

If you run maven commands in the child directory it won't know about sibling or parent dependencies. I find it easiest to run the maven commands in the outermost parent root directory with multi module projects. If you just want to build some descendent project (let's call it foo) then from the parent you can do:

mvn install -pl :foo -am

Where the pl flag is a list of artifacts you want to build and the am flag means also build their dependencies.