Son1.pom4.0.0 org.example Parentpom 1.0-SNAPSHOT ../Son1 ../Son2 Parent http://www.example.com UTF-8 1.8 1.8 junit junit4.11
Son2.pom4.0.0 org.example Son11.0-SNAPSHOT Son1 http://www.example.com UTF-8 1.8 1.8 junit junit4.11 test
4.0.0 org.example Son21.0-SNAPSHOT Son2 http://www.example.com UTF-8 1.8 1.8 junit junit4.11 test org.example Son11.0-SNAPSHOT
分别编译这三个模块,会是下面的现象:
1.编译Parent,同时会编译Son1和Son2。
[INFO] Reactor Build Order: [INFO] [INFO] Son1 [jar] [INFO] Son2 [jar] [INFO] Parent [pom]
2.编译Son1,则只会编译Son1。
[INFO] Building Son1 1.0-SNAPSHOT
3.编译Son2,如果先Son1先install,再编译Son2则成功。
如果不先install Son1,那么编译Son2的时候会因为找不到Son1失败。
[INFO] Building Son2 1.0-SNAPSHOT [WARNING] The POM for org.example:Son1:jar:1.0-SNAPSHOT is missing, no dependency information available [INFO] BUILD FAILURE
所以针对这种情况可以在Parent.pom层级下执行:
mvn clean install -pl ../Son2 -am 或者 mvn clean install -pl :Son2 -am
[INFO] Reactor Build Order: [INFO] [INFO] Son1 [jar] [INFO] Son2 [jar]
-pl, --projects
Build specified reactor projects instead of all projects
-am, --also-make
If project list is specified, also build projects required by the list
(Maven 将构建指定项目所依赖的所有项目(直接或间接))
Ref:
java - Maven Modules + Building a Single Specific Module - Stack Overflowhttps://stackoverflow.com/questions/1114026/maven-modules-building-a-single-specific-moduleMaven Tips and Tricks: Advanced Reactor Optionshttps://blog.sonatype.com/2009/10/maven-tips-and-tricks-advanced-reactor-options/



