Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I exclude certain modules from a Maven build using the commandline

Is there a way to exclude some modules from a big reactor build, similar to -pl ?

Here are a number of ways to do it persistently:

How to exclude a module from a Maven reactor build?

I want to do it from shell, or at least without modifying the poms, which I am not allowed to change.

like image 424
Bastl Avatar asked Nov 07 '12 09:11

Bastl


People also ask

How do I skip a module in Maven build?

Maven version 3.2. 1 added this feature, you can use the -pl switch (shortcut for --projects list) with ! or - (source) to exclude certain submodules. Be careful in bash the character ! is a special character, so you either have to single quote it (like I did) or escape it with the backslash character.

How do you exclude a transitive dependency in Maven?

Exclude the transitive dependencyOpen the dependency POM and find the transitive dependency you want to exclude. Copy groupId and artifactId . In your project POM, underneath your active dependency, enter exclusions and using code completion paste the copied info of the dependency you want to exclude.

Which command is used to install Maven which is required in build process?

mvn clean install is the command to do just that. You are calling the mvn executable, which means you need Maven installed on your machine.


2 Answers

Maven 3.2.1 has added this feature, you can use to specify the exact projects you want (or to exclude the projects you don't want) -pl or --projects Here's how to exclude two:

-pl "!<modulename>,!<modulename2>" 

for exclude certain modules. This can be comma separated list of values that you want to include/exclude.

Update For windows user following

> mvn clean [package|install] --projects \!groupId:artifactId 
like image 152
Yogesh_D Avatar answered Sep 19 '22 03:09

Yogesh_D


Another comment on the accepted answer, don't forget to escape the exclamation sign when running the command in bash:

> mvn clean install -pl \!module,\!module/submodule,\!groupId:artifactId 
like image 24
Radu Avatar answered Sep 21 '22 03:09

Radu