How to exclude some modules from Maven build using command line

Is there a way to exclude some modules from a large reactor assembly similar to -pl?

Here are some ways to do it persistently:

How to exclude a module from a Maven reactor assembly?

I want to do this from the shell, or at least without changing the parameters that I’m not allowed to change.

+32
maven
Nov 07 '12 at 9:12
source share
4 answers

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

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

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

+55
Apr 01 '14 at 10:48
source share

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

 > mvn clean install -pl \!module,\!module/submodule,\!groupId:artifactId 
+31
Dec 16 '14 at 13:20
source share

I do not believe that this is currently possible from the command line. Maven3 has an open function request ( http://jira.codehaus.org/browse/MNG-5230 ).

It seems that at the moment your only option is to change the pom and create a new build profile that includes only the modules you want to build.

+7
Nov 08
source share

As Yogesh_D wrote, this can be done with the -pl argument with maven 3.2.1 +

Here is an example:

 > mvn clean install -amd -pl !module,!module/submodule 

You need to list each submodule (and sub-module, etc.) manually, it does not exclude them recursively. Use a slash to separate packages. This is the path to the folder, not the identifier of the group or artifact.

+5
Dec 14 '14 at 10:06
source share



All Articles