Skip a submodule during a Maven build

后端 未结 5 1746
暖寄归人
暖寄归人 2020-11-30 17:42

We have a need to be able to skip a submodule in certain environments.

The module in question contains integration tests and takes half an hour to run. So we want t

5条回答
  •  臣服心动
    2020-11-30 18:08

    It's possible to decide which reactor projects to build by specifying the -pl command line argument:

    $ mvn --help
    [...]
     -pl,--projects                    Build specified reactor projects
                                            instead of all projects
    [...]
    

    It accepts a comma separated list of parameters in one of the following forms:

    • relative path of the folder containing the POM
    • [groupId]:artifactId

    Thus, given the following structure:

    project-root [com.mycorp:parent]
      |
      + --- server [com.mycorp:server]
      |       |
      |       + --- orm [com.mycorp.server:orm]
      |
      + --- client [com.mycorp:client]
    

    You can specify the following command line:

    mvn -pl .,server,:client,com.mycorp.server:orm clean install
    

    to build everything. Remove elements in the list to build only the modules you please.


    EDIT: as blackbuild pointed out, as of Maven 3.2.1 you have a new -el flag that excludes projects from the reactor, similarly to what -pl does:

提交回复
热议问题