1. What is Maven?

2. Maven Command Params

Param Full-param Paraphrase Explanation
-pl —projects Build specified reactor projects instead of all projects 选项后可跟随{groupId}:{artifactId}或者所选模块的相对路径(多个模块以逗号分隔)
-am —also-make If project list is specified, also build projects required by the list 表示同时处理选定模块所依赖的模块
-amd —also-make-dependents If project list is specified, also build projects that depend on projects on the list 表示同时处理依赖选定模块的模块
-N —Non-recursive Build projects without recursive 表示不递归子模块
-rf —resume-from Resume reactor from specified project 表示从指定模块开始继续处理

3. One Example

There is a multi-module maven project.

  1. .
  2. ├── HELP.md
  3. ├── mvnw
  4. ├── mvnw.cmd
  5. ├── pom.xml
  6. ├── project-a-api
  7. ├── pom.xml
  8. ├── project-b-api
  9. ├── pom.xml
  10. ├── project-common
  11. ├── pom.xml
  12. └── project-service
  13. └── pom.xml

You should package three modules of project-common, project-service, project-a-api if you want to deploy project-a-api module, because project-a-api depends on project-service and project-service depends on project-common.

You can deploy with below command:

  1. mvn clean package -P pro -pl project-common,project-service,project-a-api -am -Dmaven.test.skip=true

You can use mvnw replce mvn if you need to compile without maven environment. For example:

  1. ./mvnw clean package -P pro -pl project-common,project-service,project-a-api -am -Dmaven.test.skip=true

You need use relative path to the module you want to package if there are another modules in the project-a-api or project-b-api.

  1. mvn clean package -P pro -pl project-common,project-service,project-a-api/child-a-api -am -Dmaven.test.skip=true