Define modules list which shall be build in Maven multiproject build

我们两清 提交于 2019-12-05 18:28:47

Yes, it's possible to do this. Take a look at mvn --help:

 -pl,--projects <arg>                   Comma-delimited list of specified
                                        reactor projects to build instead
                                        of all projects. A project can be
                                        specified by [groupId]:artifactId
                                        or by its relative path.

Note in particular that an artifactId without a leading groupId still has a leading colon.

So, for example in a case where the artifactId is the same as the directory name, these three lines would all refer to the same module in Maven:

  • mvn -pl maven-core
  • mvn -pl :maven-core
  • mvn -pl org.apache.maven:maven-core

mvn seems to take the list you provide with -pl to the heart and not build any dependencies automatically.

So in addition to Joe's answer: If the project/module you're trying to build depends on other modules then you can ask mvn to build them as well with -am.

-am,--also-make
       If project list is specified, also build projects required by the list

If project list is specified = if -pl option is used

So examples become:

  • mvn -pl maven-core -am
  • mvn -pl :maven-core -am
  • mvn -pl org.apache.maven:maven-core -am
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!