我们还是参照 maven的依赖特性,冲突解决(五) 创建 maven-01 maven-02 maven-03工程,通过maven-aggregate pom工程 对这三个maven项目做一个聚合,配置如下:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.sohu.train:maven-02:jar:1.0-SNAPSHORT
[WARNING] 'dependencies.dependency.exclusions.exclusion.groupId' for junit:junit:jar is missing. @ line 38, column 16
[WARNING] 'dependencies.dependency.exclusions.exclusion.artifactId' for junit:junit:jar is missing. @ line 38, column 16
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order: //构建 maven 的反应堆,执行清理 编译的顺序
[INFO]
[INFO] maven-02
[INFO] maven-01
[INFO] maven-03
[INFO] maven-aggregate
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-02 1.0-SNAPSHORT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-02 ---
[INFO] Deleting E:\train\test\maven-02\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-02 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\train\test\maven-02\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-02 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:\train\test\maven-02\target\classes
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-01 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-01 ---
[INFO] Deleting E:\train\test\maven-01\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-01 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-01 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:\train\test\maven-01\target\classes
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-03 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-03 ---
[INFO] Deleting E:\train\test\maven-03\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-03 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\train\test\maven-03\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-03 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:\train\test\maven-03\target\classes
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-aggregate 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-aggregate ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary: // 可以看到 对3个maven项目 一起执行编译
[INFO]
[INFO] maven-02 ........................................... SUCCESS [ 1.874 s]
[INFO] maven-01 ........................................... SUCCESS [ 0.108 s]
[INFO] maven-03 ........................................... SUCCESS [ 0.158 s]
[INFO] maven-aggregate .................................... SUCCESS [ 0.002 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.263 s
[INFO] Finished at: 2016-01-15T14:35:41+08:00
[INFO] Final Memory: 14M/227M
[INFO] ------------------------------------------------------------------------
这样我们就完成 maven对子模块的聚合 ,像我们平常用的dubbo jetty tomcat spring hibernate等等 都是按模块 去开发,一次编译 各个模块都能紧密联系在一起了。我们在平常开发项目也需要适当的去分模块开发,