onknows
onknows

Reputation: 6681

How to exclude Maven modules on command line

Purportedly you can exclude modules on the command line for example by running command like

mvn clean install -pl \!modulename

This does not seem to work (anymore).

Btw, include the module also doesn't work

mvn clean install -pl modulename

Maven reactor will not find the module and fail.

[ERROR] Could not find the selected project in the reactor: modulename -> [Help 1]

The module modulename does exist however. Reactor will produce its name in the list of build modules when doing an ordinary build.

[INFO] modulename

Is there a way to exclude modules on the command line? I don't want to change the pom file if it all possible.

Upvotes: 10

Views: 21495

Answers (2)

wei Lan
wei Lan

Reputation: 11

if you have a module named: app-server, then you can try this: clean install -pl !app-server.--

For learning more

Upvotes: 1

Gene
Gene

Reputation: 11267

Lets say in your parent pom.xml, your module structure is this:

enter image description here

Then if I want to exclude modules "core" and "app1", the command would be:

mvn -pl '!core,!app1' clean install

So the end result with the -pl flag is:

enter image description here

Note:

Put the module names from the parent pom.xml (like above), not the <name> in the sub-modules.

Put the -pl flag before "clean install".

Also, there should be no spaces between each of the commas separating the module names.

This is what the build looks like without the -pl flag set: enter image description here

Upvotes: 25

Related Questions