Define modules list which shall be build in Maven multiproject build

£可爱£侵袭症+ 提交于 2019-12-07 13:47:58

问题


I would like to use Maven -pl option to define which specific modules shall be included into reactor. The option works if list of module's paths is provided. Unfortunately, providing module's artifactIds is not working at all. Sonatype 'Maven: The Complete Reference' docs are using multiproject example where directories names are matching artifactIds:

http://books.sonatype.com/mvnref-book/reference/_using_advanced_reactor_options.html

Is it possible to use -pl option with artifactId?


回答1:


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



回答2:


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


来源:https://stackoverflow.com/questions/26429476/define-modules-list-which-shall-be-build-in-maven-multiproject-build

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