创建项目

xxx - 继承自testDep.PPP

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>testDep.XXX</groupId>
<artifactId>xxx</artifactId>
<packaging>jar</packaging> <name>xxx</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <parent>
<groupId>testDep.PPP</groupId>
<artifactId>ppp</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>

yyy - 继承自testDep.PPP

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>testDep.YYY</groupId>
<artifactId>yyy</artifactId>
<packaging>jar</packaging> <name>yyy</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <parent>
<groupId>testDep.PPP</groupId>
<artifactId>ppp</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>

zzz - 在zzz中聚合xxx和yyy

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>testDep.ZZZ</groupId>
<artifactId>zzz</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging> <name>zzz</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<modules>
<module>../xxx</module>
<module>../yyy</module>
</modules>
</project>

ppp - 父项目

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>testDep.PPP</groupId>
<artifactId>ppp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging> <name>ppp</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>3.8.1</junit.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

验证

ppp执行clean install

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ppp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ ppp ---
[INFO] Deleting D:\Anliven-Running\Zen\EclipseProjects\ppp\target
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ ppp ---
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\ppp\pom.xml to D:\DownLoadFiles\apache-maven-repo\testDep\PPP\ppp\0.0.1-SNAPSHOT\ppp-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.578 s
[INFO] Finished at: 2017-10-24T16:43:09+08:00
[INFO] Final Memory: 9M/309M
[INFO] ------------------------------------------------------------------------

xxx执行clean install

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building xxx 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ xxx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Anliven-Running\Zen\EclipseProjects\xxx\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ xxx ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ xxx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Anliven-Running\Zen\EclipseProjects\xxx\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ xxx ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ xxx ---
[INFO] Surefire report directory: D:\Anliven-Running\Zen\EclipseProjects\xxx\target\surefire-reports -------------------------------------------------------
T E S T S
-------------------------------------------------------
Running testDep.XXX.xxx.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ xxx ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ xxx ---
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\xxx\target\xxx-0.0.1-SNAPSHOT.jar to D:\DownLoadFiles\apache-maven-repo\testDep\XXX\xxx\0.0.1-SNAPSHOT\xxx-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\xxx\pom.xml to D:\DownLoadFiles\apache-maven-repo\testDep\XXX\xxx\0.0.1-SNAPSHOT\xxx-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.520 s
[INFO] Finished at: 2017-10-24T16:47:36+08:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------

zzz 执行clean install

从输出日志可以看到进行了3次构建,并安装到本地仓库中:

Building xxx 0.0.1-SNAPSHOT

Building yyy 0.0.1-SNAPSHOT

Building zzz 0.0.1-SNAPSHOT

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] xxx
[INFO] yyy
[INFO] zzz
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building xxx 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ xxx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Anliven-Running\Zen\EclipseProjects\xxx\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ xxx ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ xxx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Anliven-Running\Zen\EclipseProjects\xxx\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ xxx ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ xxx ---
[INFO] Surefire report directory: D:\Anliven-Running\Zen\EclipseProjects\xxx\target\surefire-reports -------------------------------------------------------
T E S T S
-------------------------------------------------------
Running testDep.XXX.xxx.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ xxx ---
[INFO] Building jar: D:\Anliven-Running\Zen\EclipseProjects\xxx\target\xxx-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ xxx ---
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\xxx\target\xxx-0.0.1-SNAPSHOT.jar to D:\DownLoadFiles\apache-maven-repo\testDep\XXX\xxx\0.0.1-SNAPSHOT\xxx-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\xxx\pom.xml to D:\DownLoadFiles\apache-maven-repo\testDep\XXX\xxx\0.0.1-SNAPSHOT\xxx-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building yyy 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ yyy ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Anliven-Running\Zen\EclipseProjects\yyy\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ yyy ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ yyy ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Anliven-Running\Zen\EclipseProjects\yyy\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ yyy ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ yyy ---
[INFO] Surefire report directory: D:\Anliven-Running\Zen\EclipseProjects\yyy\target\surefire-reports -------------------------------------------------------
T E S T S
-------------------------------------------------------
Running testDep.YYY.yyy.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ yyy ---
[INFO] Building jar: D:\Anliven-Running\Zen\EclipseProjects\yyy\target\yyy-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ yyy ---
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\yyy\target\yyy-0.0.1-SNAPSHOT.jar to D:\DownLoadFiles\apache-maven-repo\testDep\YYY\yyy\0.0.1-SNAPSHOT\yyy-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\yyy\pom.xml to D:\DownLoadFiles\apache-maven-repo\testDep\YYY\yyy\0.0.1-SNAPSHOT\yyy-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building zzz 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ zzz ---
[INFO] Installing D:\Anliven-Running\Zen\EclipseProjects\zzz\pom.xml to D:\DownLoadFiles\apache-maven-repo\testDep\ZZZ\zzz\0.0.1-SNAPSHOT\zzz-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] xxx ................................................ SUCCESS [ 2.282 s]
[INFO] yyy ................................................ SUCCESS [ 0.351 s]
[INFO] zzz ................................................ SUCCESS [ 0.007 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.819 s
[INFO] Finished at: 2017-10-24T16:43:49+08:00
[INFO] Final Memory: 12M/309M
[INFO] ------------------------------------------------------------------------

Maven - 实例-6-聚合与继承的更多相关文章

  1. maven项目的聚合与继承

    maven项目的聚合与继承: 一.聚合 如果我们想一次构建多个项目模块,那我们就需要对多个项目模块进行聚合 1.1.聚合配置代码 1 <modules> 2 <module>模 ...

  2. Maven学习总结——聚合与继承

    一.聚合 如果我们想一次构建多个项目模块,那我们就需要对多个项目模块进行聚合 1.1.聚合配置代码 1 <modules> 2 <module>模块一</module&g ...

  3. maven 依赖、聚合和继承 (转)

    Maven 插件和仓库 Maven 本质上是一个插件框架,它的核心并不执行任何具体的构建任务,仅仅定义了抽象的生命周期,所有这些任务都交给插件来完成的.每个插件都能完成至少一个任务,每个任务即是一个功 ...

  4. maven学习(十一)——maven中的聚合与继承

    一.聚合 如果我们想一次构建多个项目模块,那我们就需要对多个项目模块进行聚合 1.1.聚合配置代码 <modules> <module>模块一</module> & ...

  5. Java-Maven(七):Eclipse中Maven依赖、聚合、继承特性

    之前通过学习了解,maven集成到eclipse中的如何创建项目,以及maven命令插件在eclipse中安装后的用法.那么接下来我们将会学习一些maven在项目中的一些特性,及如何使用. Maven ...

  6. (五)Maven中的聚合和继承

    一.为什么要聚合? 定义:我们在开发过程中,创建了2个以上的模块,每个模块都是一个独立的maven project,在开始的时候我们可以独立的编译和测试运行每个模块,但是随着项目的不断变大和复杂化,我 ...

  7. Maven专题2——聚合与继承

    聚合 聚合模块的<packaging>元素为pom 聚合模块通过<modules>元素标识自己的子模块,每个子模块对应了一个module元素 module元素中指定的是子模块所 ...

  8. Maven聚合与继承的实例讲解(二)

    继续上一节讲Maven的内容,我们这个节继续讲Maven继承和聚合的其他内容.    现在我们新建一个实例来测试Maven有关于聚合的部分     测试开始 一.建立以pom为packaging的项目 ...

  9. (十四)Maven聚合与继承

    1.Maven聚合 我们在平时的开发中,项目往往会被划分为好几个模块,比如common公共模块.system系统模块.log日志模块.reports统计模块.monitor监控模块等等.这时我们肯定会 ...

随机推荐

  1. EF连接Mysql 表'TableDetails'中的列'IsPrimaryKey'的值为DBNull

    无法生成模型,因为存在以下异常:'System.Data.StrongTypingException:表'TableDetails'中的列'IsPrimaryKey'的值为DBNull.---> ...

  2. 多层josn数据 修改

    var aa = { a: 1, b: { c: 1, d: 1 }, e: [{ f: 1, g: 2 }, { h: 1, i: { j: 3, k: [{ l: 55, m: [1, 2, 3, ...

  3. JAVA结合testng断言verify(断言失败不中断继续执行)

    原理: 1.自已构造一个断言类,把Assert.assertEquals给try catch住. 2.利用testng的监听类在测试方法运行结束后进行分析. 代码: 断言类: package com. ...

  4. pyspider--post

    #!/usr/bin/env python# -*- encoding: utf-8 -*-# Created on 2018-08-19 14:47:28# Project: HBGGZY_SBJ ...

  5. ASP 错误捕捉,处理

    Asp利用 On Error Resume Next捕捉异常,根据Err.Number判断是否有错误 注:On Error Goto 0取消捕捉异常 模板文件页面 <% Response.Buf ...

  6. spring入门--spring入门案例

    spring是一个框架,这个框架可以干很多很多的事情.感觉特别吊.但是,对于初学者来说,很难理解spring到底是干什么的.我刚开始的时候也不懂,后来就跟着敲,在后来虽然懂了,但是依然说不明白它到底是 ...

  7. Log4j 日志组件

    官网:https://logging.apache.org/log4j/2.x/ 使用 Log4j 的步骤: 第一步 引入 Log4j 的 jar 包 1. 直接下载 log4j-x.x.x.jar ...

  8. [uboot] (第五章)uboot流程——uboot启动流程

    http://blog.csdn.net/ooonebook/article/details/53070065 以下例子都以project X项目tiny210(s5pv210平台,armv7架构)为 ...

  9. 深入浅出WPF文摘

    第一部分 深入浅出XMAL 第一章 XMAL概览 第二章 从零起步认识XMAL 第三章 系统学习XMAL语法 第四章 X名称空间详解 第五章 控件与布局 GUI:图形化用户界面 逻辑树: 可视树: : ...

  10. wind量化交易

    https://www.joinquant.com/study?f=home&m=memu https://www.v2ex.com/member/mushroomqiu https://sa ...