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

后端 未结 6 992
不知归路
不知归路 2020-12-04 20:54

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 fr

相关标签:
6条回答
  • 2020-12-04 21:33

    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.

    0 讨论(0)
  • 2020-12-04 21:36

    comma separated module name enclosed with double quotes. eg::

    mvn install -pl "!Module1, !Module2" 
    
    0 讨论(0)
  • 2020-12-04 21:38

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

    Here's an example:

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

    You need to list every sub-module (and sub-sub-module etc) manually, it does not exclude them recursively. Use the slash for package separation. It's the folder path, not the group or artifact id.

    0 讨论(0)
  • 2020-12-04 21:40

    I don't believe this is currently possible from the command line. There is an open feature request in maven3 for this very thing (http://jira.codehaus.org/browse/MNG-5230).

    Looks like your only option at this point is to modify the pom and create a new build profile that includes only the modules you want to build.

    0 讨论(0)
  • 2020-12-04 21:50

    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
    
    0 讨论(0)
  • 2020-12-04 21:52

    in 2019 it's

    mvn install -pl !:module1
    

    (Windows 10 cmd)

    0 讨论(0)
提交回复
热议问题