maven-pom文件结构说明
<a name="bc4f21f4"></a>
1 简介
为了更好的反映代码质量,并且为基础考核提供基础数据,在maven中我们添加相关报表插件分别生成代码规范、潜在bug、单元测试、单元测试覆盖率等项目报告,为提高项目代理质量提供指导方案。
<a name="25ffe788"></a>
2 项目模板
项目模板以开源项目为准,项目地址为 https://github.com/xuxueli/xxl-job/
<a name="b3720c7d"></a>
3 root pom文件结构
<a name="dc1ddd0c"></a>
3.1 POM的模型版本
<modelVersion>4.0.0</modelVersion>
说明:在Maven2和Maven3中,只支持4.0.0版本。
<a name="9b0bd3ae"></a>
3.2 基本配置
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<packaging>...</packaging>
<parent>...</parent>
<modules>...</modules>
<properties>...</properties>
<dependencyManagement>...</dependencyManagement>
<dependencies>...</dependencies>
说明:
- groupId:构件所属的组织ID
- artifactId:构件的ID
- version:构件的当前版本
- packaging:打包方式,打包方式有pom、jar、war等等,一般父项目的packaging为pom
- parent:maven中存在项目的继承关系,parent用来指定父项目
- modules:父项目所包含的者子模块
- properties:项目参数配置
- dependencyManagement:依赖管理,一般在父项目中配置
- dependencies:依赖jar包,一般在子模块中配置,引用父项目dependencyManagement中的依赖配置,同时不需要配置依赖的版本号,方便父项目对依赖版本的统一管理
<a name="7463dbc3"></a>
3.3 Build配置
<build>...</build>
<reporting>...</reporting>
说明:
- build: 为项目构建配置,其中会包含很多插件
- reporting:项目报告,其中包含很多插件用于生成报告
<a name="d5d99660"></a>
3.4 环境配置
<issueManagement>...</issueManagement>
<ciManagement>...</ciManagement>
<mailingLists>...</mailingLists>
<distributionManagement>...</distributionManagement>
<scm>...</scm>
<prerequisites>...</prerequisites>
<repositories>...</repositories>
<pluginRepositories>...</pluginRepositories>
<profiles>...</profiles>
说明:
- issueManagement:给出defect tracking system及其访问URL
- ciManagement:给出Continuous Integration Management、其URL和notifier
- distributionManagement: 构件的发布管理
- scm:git或svn代码管理地址
- prerequisites: POM执行的前提条件,目前只支持对Maven版本的要求
- mailingLists: 开发人员或用户的邮件列表
- repositories:仓库列表
- pluginRepositories:插件仓库列表
- profiles: 环境配置管理
<a name="3dab0c05"></a>
3.5 其他信息
<name>...</name>
<description>...</description>
<url>...</url>
<inceptionYear>...</inceptionYear>
<licenses>...</licenses>
<organization>...</organization>
<developers>...</developers>
<contributors>...</contributors>
说明:
- name:项目的名称代号
- description:项目的说明
- url:项目的官网URL
- inceptionYear:项目的开发年份
- licenses:项目使用的License。其中可以包含多个license,license具体又包含如下子属性
- organization:包含组织的name,组织的官网url
- developers:其中的developer包含id, name, email, url, organization, organizationUrl, roles, timezone
- contributors:其中的contributor包含与developer基本相同的属性,除了没有id属性之外
<a name="d03e34b2"></a>
4 maven report插件模板
maven report中包含javadoc、源码、单元测试、单元测试覆盖率、类库依赖等信息,后面将对这些内容详细说明。
网友评论