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.
.├── HELP.md├── mvnw├── mvnw.cmd├── pom.xml├── project-a-api│ ├── pom.xml├── project-b-api│ ├── pom.xml├── project-common│ ├── pom.xml└── project-service└── 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:
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:
./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.
mvn clean package -P pro -pl project-common,project-service,project-a-api/child-a-api -am -Dmaven.test.skip=true
