Shotgun
Shotgun

Reputation: 678

Maven run multi-module application with Jetty

I have an issue launching my multi-modal application, the application looks like this :

Everything is configured well so that the parent knows the modules, and each module is related to its parent using pom.xml files.

Now when I want to run the whole application I have to go through each module and execute the command mvn jetty:run separately.

Is there any way I can do that simply by going to the Parent's folder and doing a single command?

Upvotes: 1

Views: 1351

Answers (2)

MariuszS
MariuszS

Reputation: 31567

Solution without changing directory - from project root directory, but with command per jetty

Run jetty from selected module

mvn -pl Module1/ jetty:run 
mvn -pl Module2/ jetty:run 

Used option: -pl,--projects <arg>

Comma-delimited list of specified reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by its relative path.

Run jetty from specified pom.xml - alternative version

mvn -f Module1/pom.xml jetty:run 
mvn -f Module2/pom.xml jetty:run 

Used option: -f,--file <arg>

Force the use of an alternate POM file (or directory with pom.xml).

In general module is not a separete application, but part of application (libraries, commons etc). In this case one jetty:run is required by project.

Upvotes: 2

Kees van Dieren
Kees van Dieren

Reputation: 1290

Are you working on a Linux / Unix shell based environment?

On the shell (in directory parent) you could try the following command:

find ./ -name pom.xml | grep -E "Module1|Module2" | xargs -n 1 -P 10 mvn jetty:run -f

Upvotes: 2

Related Questions