Maven:站点生成

一、生成简单的站点 
用户可以让Maven自动生成一个Web站点,以Web的形式发布如项目描述、版本控制系统地址、缺陷跟踪系统地址等,更便捷、更快速地为团队提供项目当前的状态信息; 
1.在pom.xml文件中,配置maven-site-plugin插件(Maven的site生命周期如果默认绑定了site插件就可以不配置): 
<project> 
    ... ...  
    <build> 
        <plugins> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-site-plugin</artifactId> 
                <version>3.3</version> 
            </plugin> 
        </plugins> 
    </build> 
    ... ...  
</project> 
2.配置正确版本之后,在项目之下运行mvn site就能直接生成一个最简单的站点; 
C:\Users\chengxiang.peng.QUNARSERVERS\QunarGitSources\phone_spider_project>mvn site 
[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building check phone 1.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-site-plugin:3.3:site (default-site) @ phoneproject --- 
[WARNING] Report plugin org.apache.maven.plugins:maven-project-info-reports-plugin has an empty version. 
[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. 
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:2.9 
[WARNING] No project URL defined - decoration links will not be relativized! 
[INFO] Rendering site with org.apache.maven.skins:maven-default-skin:jar:1.0 skin. 
[INFO] Generating "Dependencies" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Dependency Convergence" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Dependency Information" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "About" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Plugin Management" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Plugins" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Summary" report    --- maven-project-info-reports-plugin:2.9 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 29.989 s 
[INFO] Finished at: 2016-10-20T12:09:41+08:00 
[INFO] Final Memory: 26M/357M 
[INFO] ------------------------------------------------------------------------ 
3.待Maven运行完成后,可以再项目的target/site/目录下找到Maven生成的站点文件,包括dependencies.html、dependency-convergence.html、index.html和css、images文件夹; 
Project [Phoneproject] config target images dependencies.html dependency-convergence,html dependency-info.html Index.html plugin-management.html plugins.html project-info.html project-summary.htm .gitignore PhoneProject.iml m pom.xml External Libraries
4.点击index.html文件,打开生成的站点; 
C O localhost:63342/PhoneProject/target/site/project-info.htmI check phone Last Published: 2016-10-20 | version: 1.0-SNAPSHOT check phone Project Documentation Project Information Dependencies Dependency Convergence Dependency Information About Plugin Management Plugins Summary maven Project Information This document provides an overview of the various documents and links that are part of this project's general information. All of this content is automatically generated by Maven on behalf of the project. Overview Document Dependencies Dependency Convergence Dependency Information About Plugin Management Plugins Summary Description This document lists the project's dependencies and provides information on each dependency. This document presents the convergence of dependency versions across the entire project, and its sub modules. This document describes how to to include this project as a dependency using various dependency management tools. There is currently no description associated with this project. This document lists the plugins that are defined through pluginManagement. This document lists the build plugins and the report plugins used by this project. This document lists other related information of this project Copyright 2016. All Rights Reserved.
二、丰富项目的信息 
1.默认情况下,Maven生成的站点包含了很多项目的信息链接,这其实是由一个名为maven-project-info--reports-plugin的插件(Maven3中,该插件内置在maven-site-plugin中,Maven2内置在核心源码中)生成的;该插件会基于POM配置生成下列项目信息报告(见上站点截图): 
  关于(about):项目描述; 
  持续集成(Continuous Integeration):项目持续化集成服务器信息; 
  依赖(Dependencies):项目依赖信息,包括传递性依赖、依赖图、依赖许可证以及依赖文件的大小、所包含的类的数目; 
  依赖收敛(Dependency Convergence):针对多个模块项目生成,提供一些依赖健康状况分析; 
  依赖管理(Dependency Management):基于项目的 依赖管理生成的报告; 
  问题追踪(Issue Tracking):项目问题追踪系统信息; 
  邮件列表(Mailing Lists):项目的邮件列表信息; 
  插件管理(Plugin Management):项目所有项目插件的列表; 
  项目许可证(Project License):项目许可证信息; 
  项目概述(Project Summary):项目概述包括坐标、名称、描述等; 
  项目团队(Project Team):项目团队信息; 
  源码仓库(Source Repository):项目的源码仓库信息; 
2.Maven不会凭空生成信息,只有用户在POM中提供了相关配置后,站点才可能包含这些信息的报告。为了让站点包含完整的项目信息,需要配置PMO如下: 
<project> 
    ... ...  
    <url>http://phoneproject.qunar.com</url> 
    <!--项目描述信息--> 
    <description>check phone description.</description> 
    <!--源码仓库信息--> 
    <scm> 
        <connection>scm:git:http://gitlab.corp.chengxiang.com/mobile_hotel_res/phone_spider_project</connection> 
        <developerConnection>scm:git:[email protected]:mobile_hotel_res/phone_spider_project.git 
        </developerConnection> 
        <url>http://gitlab.corp.chengxiang.com/mobile_hotel_res/phone_spider_project</url> 
    </scm> 
    <!--持续化集成服务信息--> 
    <ciManagement> 
        <system>Jenkins</system> 
        <url>http://ci.chengxiang.com/phoneproject</url> 
    </ciManagement> 
    <!--项目成员信息--> 
    <developers> 
        <developer> 
            <id>chengxiang.peng</id> 
            <name>chengxiang.peng</name> 
            <email>[email protected]</email> 
            <timezone>8</timezone> 
        </developer> 
    </developers> 
    <!--问题跟踪信息--> 
    <issueManagement> 
        <system>JIRA</system> 
        <url>http://jira.chengxiang.com/phoneproject</url> 
    </issueManagement> 
    ... ...  
</project> 
3.执行mvn site重新生成站点,发现对比简单站点,多生成了如 "CI Management" report、"Source Code Management" report等; 
C:\Users\chengxiang.peng.QUNARSERVERS\QunarGitSources\phone_spider_project>mvn site 
[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building check phone 1.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-site-plugin:3.3:site (default-site) @ phoneproject --- 
[WARNING] Report plugin org.apache.maven.plugins:maven-project-info-reports-plugin has an empty version. 
[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. 
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:2.9 
[INFO] Relativizing decoration links with respect to project URL: http://phoneproject.qunar.com 
[INFO] Rendering site with org.apache.maven.skins:maven-default-skin:jar:1.0 skin. 
//新增的报告生成 
[INFO] Generating "CI Management" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Dependencies" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Dependency Convergence" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Dependency Information" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "About" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Issue Management" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Plugin Management" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Plugins" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Team" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Source Code Management" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Summary" report    --- maven-project-info-reports-plugin:2.9 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 19.624 s 
[INFO] Finished at: 2016-10-20T15:21:46+08:00 
[INFO] Final Memory: 26M/354M 
[INFO] ------------------------------------------------------------------------

3.有些时候,我们并不需要生成某些项目信息,如可能不想公开源码仓库信息。可以通过maven-project-info-reports-plugin选择性生成信息项目,pom.xml配置如下: 

<project> 
    ... ...  
    <!--报告配置--> 
    <reporting> 
        <plugins> 
            <!--maven-project-info-reports-plugin报告插件集成在site中,故不同配置build/plugins/plugin。配置生成什么报告, 
            如下配置只生成dependencies、project-team和mailing-list--> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-project-info-reports-plugin</artifactId> 
                <version>2.9</version> 
                <reportSets> 
                    <reportSet> 
                        <reports> 
                            <report>dependencies</report> 
                            <report>project-team</report> 
                        </reports> 
                    </reportSet> 
                </reportSets> 
            </plugin> 
        </plugins> 
    </reporting> 
    ... ...
</project>
4.mvn site生成站点: 
C:\Users\chengxiang.peng.QUNARSERVERS\QunarGitSources\phone_spider_project>mvn site 
[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building check phone 1.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-site-plugin:3.3:site (default-site) @ phoneproject --- 
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:2.9 
[INFO] Relativizing decoration links with respect to project URL: http://phoneproject.qunar.com 
[INFO] Rendering site with org.apache.maven.skins:maven-default-skin:jar:1.0 skin. 
//只生成了上面配置的Dependencies和Team报告 
[INFO] Generating "Dependencies" report    --- maven-project-info-reports-plugin:2.9 
[INFO] Generating "Team" report    --- maven-project-info-reports-plugin:2.9 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 36.054 s 
[INFO] Finished at: 2016-10-20T15:30:33+08:00 
[INFO] Final Memory: 24M/275M 
[INFO] ------------------------------------------------------------------------ 
三、项目报告插件
除了默认的项目信息报告,Maven社区还提供了大量报告插件,只要稍加配置,用户就能让Maven自动生成各种内容丰富的报告。一般的插件在<project><build><plugins>配置,报告插件在<project><reporting><plugins>配置: 
1.JavaDocs:使用JDK的javadoc工具,基于项目源代码生成JavaDocs文档; 
pom.xml配置如下: 
<project> 
    ... ...  
    <!--报告配置--> 
    <reporting> 
        <plugins> 
            <!--生成Javadoc文档--> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-javadoc-plugin</artifactId> 
                <version>2.7</version> 
            </plugin> 
        </plugins> 
    </reporting> 
    ... ...  
</project> 

执行mvn site生成站点中,包含javadoc文档Project Reports->JavaDocs如下:
comchengxiangphoneproject comchengxianqphoneprojectconfig comchengxianqphoneprojectdao comchengxianqphoneprojectdaoimpl comchengxianqphoneprojectdomaimarea comchengxianqphoneprojectdomaimareafeponse comchengxianqphoneprojectdomaimphone comchengxianqphoneprojectdomain.proxy comchengxianqphoneprojectservice.impl com.chengxiang.phoneproject.utils Area AreaDaolmpl AreaResponse Areaservicelmpl aaseModel BaseReponse CheckCallable CheckState Config DBPoolScheduleThread GetPhoneThread HttpUtils IAreaDao 'Area Service IPhoneDao IPh on e Service IPModeI JdbcUtils Main check phone I.O.SNAPSHOT API com.chengxiang.phoneproject com.chengxiang.phoneproject.config com.chengxiang.phoneproject.dao com.chengxiang.phoneproject.dao.impl com.chengxiang.phoneproject.domain.area com.chengxiang.phoneproject.domain.area.reponse com.chengxiang.phoneproject.domain.phone com.chengxiang.phoneproject.domain.proxy com.chengxiang.phoneproject.service com.chengxiang.phoneproject.service.impl com.chengxiang.phoneproject.thread com.chengxiang.phoneproject.utils Copyright 02015 All Rights Reservec[

2.Source Xref:能够随时随地打开浏览器访问项目的最新源代码;
pom.xml配置: 

<project> 
    ... ...  
    <!--构建配置--> 
    <build> 
        <plugins> 
            <!--引用插件配置--> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-jxr-plugin</artifactId> 
                <version>2.2</version> 
            </plugin> 
        </plugins> 
    </build> 
    <!--报告配置--> 
    <reporting> 
        <plugins> 
            <!--报告生成配置--> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-jxr-plugin</artifactId> 
                <version>2.2</version> 
            </plugin> 
        </plugins> 
    </reporting> 
    ... ...  
</project>

执行mvn site生成站点中,包含源码文档Project Reports->Source Xref如下:
All Classes Packages com chengxiang.phoneproject com chengwang.phoneproect.config com chengxiang.phoneproject.dao com chengxiang.phoneproject.dao.impl com chengwang.phoneproect.domain.area com chengwang.phoneproect.domain.area_repons com chengxiang.phoneproject.domain.ohone com chengxiang.phoneproject.domain.proxy com chengwang.phoneproect.serwce com chengwang. phoneproect. service. impl All Classes AmountRu e AreaDaoImpl AreaReponseData AreaResponse AreaServiceImpl BaseMode BaseReponse CheckCalIable CheckState Config DBPoolScheduIeThread GetPhoneThread HttplJtils IAreaDao V ew Javadoc pa*age com. chengxiang. phoneproject. domai_n. area: * Created by chervxåmg. pere on 2015/9/22. public class { private String mAreaId: private St ring mA_reaUame: private String mHomeProvi_nce private String mOper*eId: private String mSaIeCode mAreaId = mA_reaUame = . mHomeProvi_nce = mOper*eId = mSaIeCode = * & a_ran aAreaId * & a_ran aArea,Vane * arm aHoneProvince public Area (String a_AreaId, String this. mAreaId = aAreaId: this. mAreaName = aAreaName: this. nHomeProvince = aHomeProvince: String aHomeProvi_nce)  

3.CheckStyle:帮助开发人员遵循编码规范的工具,能根据一套规则自动检查Java代码,使得团队能够方便地定义自己的编码规范; 
pom.xml配置如下: 
<project> 
    ... ...  
    <!--构建配置--> 
    <build> 
        <plugins> 
            <!--代码规范检测插件--> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-checkstyle-plugin</artifactId> 
                <version>2.5</version> 
                <!--在插件的目标mvn site:site中有效,配置checkstyle检测规则--> 
                <configuration> 
                    <configLocation>${project.basedir}/config/checkstyle/checkstyle.xml</configLocation> 
                </configuration> 
            </plugin> 
        </plugins> 
    </build> 
    <!--报告配置--> 
    <reporting> 
        <plugins> 
            <!--代码规范检测报告--> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-checkstyle-plugin</artifactId> 
                <version>2.5</version> 
                <!--在mvn site生命周期有效,配置checkstyle检测规则--> 
                <configuration> 
                    <configLocation>${project.basedir}/config/checkstyle/checkstyle.xml</configLocation> 
                </configuration> 
            </plugin> 
        </plugins> 
    </reporting> 
    ... ...  
</project> 
Checkstyle.xml配置如下(详细配置信息,查看官方文档:http://checkstyle.sourceforge.net/checks.html): 
<?xml version="1.0"?> 
<!DOCTYPE module PUBLIC 
        "-//Puppy Crawl//DTD Check Configuration 1.3//EN" 
        "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> 
<module name="Checker"> 
    <module name="TreeWalker"> 
        <!--包名检测--> 
        <module name="PackageName"> 
            <property name="format" value="^[a-z]+(\.[a-z0-9]*)*$"/> 
        </module> 
       <!--类名检测--> 
        <module name="TypeName"> 
            <property name="format" value="^[A-Z][a-zA-Z0-9]*$"/> 
            <property name="tokens" value="CLASS_DEF"/> 
        </module> 
        … …. 
        <!--成员变量检查--> 
         <module name="LocalVariableName"> 
            <property name="format" value="^[a-z][a-zA-Z_0-9]*$"/> 
            <!--该属性在IEAD中不包裹,在mvn site报错,mvn site -X可以查看详细信息--> 
            <property name="allowOneCharVarInForLoop" value="false"/> 
        </module> 
    </module> 
    … ….. 
</module>

执行mvn site生成站点中,包含源码文档Project Reports->CheckStyle如下:
check phone Last Published: 2016-10-20 | version: 1.0-SNAPSHOT Project Documentation Project Information Java Docs Source Xref maven heckstyle Results e following document contains the results of Checkstyle Summary Files Files Files I nfos Warnings com/chengxiang/phoneproject/thread/checkcallable.java Rules Rules PackageName format: Violations check phone Errors Seve rity Error  

4.PMD:Java源代码分析工具,能够寻找代码中的问题,包括潜在的bug、无用的代码、可优化的代码、重复代码以及过于复杂的表达式; 
pom.xml配置如下: 
<project> 
    ... ... 
    <!--构建配置--> 
    <build> 
        <plugins> 
            <!--代码问题分析插件--> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-pmd-plugin</artifactId> 
                <version>3.7</version> 
            </plugin> 
        </plugins> 
    </build> 
    <!--报告配置--> 
    <reporting> 
        <plugins> 
            <!--代码问题分析报告--> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-pmd-plugin</artifactId> 
                <version>3.7</version> 
            </plugin> 
        </plugins> 
    </reporting> 
    ... ...  
</project> 
执行mvn site生成站点中,包含源码文档Project Reports->PMD如下:
check phone Last Published: 2016-10-20 | version: 1.0-SNAPSHOT Project Documentation Project Information Project Reports JavaDocs Source Xref Checkstyle PMD Built by: maven PMD Results The following document contains the results of PMD 5.5.1. Files com/chengxiang/phoneproject/thread/CheckCallable.java Violation Avoid empty if statements com/chengxiang/phoneproject/thread/DBPoolScheduleThread.java Violation rriding method merely calls super check phone Line 218-220 Line 8-10 Copyright 2016. All Rights Reserved.
关于PMD自定义规则详情查看(http://pmd.sourceforge.net/pmd-4.3.0/howtowritearule.html) 
5.ChangeLog:基于版本控制系统中就近的变更记录生成三份报告(貌似只支持github); 
6.Cobertura:生成测试覆盖率报告; 
pom.xml配置: 
<project> 
    ... ...  
    <!--构建配置--> 
    <build> 
        <plugins> 
            <!--代码覆盖率检测插件--> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>cobertura-maven-plugin</artifactId> 
                <version>2.7</version> 
            </plugin> 
        </plugins> 
    </build> 
    <!--报告配置--> 
    <reporting> 
        <plugins> 
            <!--代码覆盖检测报告--> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>cobertura-maven-plugin</artifactId> 
                <version>2.7</version> 
            </plugin> 
        </plugins> 
    </reporting> 
    ... ...  
</project> 
执行mvn site生成站点中,包含源码文档Project Reports->Coberatura Test如下: 
Packages Coverage Report All Packaqes - Ali Packages # Classes Line Coverage Branch Coverage Complexitv com com com com com com com com com com com com . chen . chen . chen . chen . chen xlan xlan xlan xlan xlan xlan xlan xlan xlan xlan xlan . hone . hone . hone . hone . hone ro ect.dao ro ect.domain. ro ect.domain. ro ect.domain. ro ect.utils area. hon rox on se com com com com com com com com com com com chen . chen . chen xlan xlan xlan xlan xlan xlan xlan xlan xlan xlan xlan hone . hone . hone ro'ect ro ect.dao ro ect.utils Package area.re on se ro 16-10-20 1.55 1.444 1.125 3.056 All Packages Classes Area (0%) AreaDao[m I (0%) AreaRes onse (0%) AreaService[m I (0%) BaseModel (0%) BaseRe onse (0%) Report generated by Cobertura 2.1.1 on
四、自定义站点外观 
Maven生成的站点非常灵活,除了前面提到的标准信息报告和其它创建生成的报告,还能够自定义站点的外观和布局: 
1.创建如下文件目录(src/site): 
Project [Phoneproject] config t site apttest.apt faqtest.fml resources images right.jpg
2.分别创建site.xml、faqtest.fml和apttest.apt文件: 
src/site/site.xml文件(定义了站点描述符,头部内容及外观-1、2、3、4,皮肤-7,导航边栏-5,创建自定义页面-5):
<?xml version="1.0" encoding="UTF-8"?> 
<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"> 
    <!--1.左边栏--> 
    <bannerLeft> 
        <name>Phone Site</name> 
        <!--访问url图片--> 
        <src>http://tika.apache.org/asf-logo.gif</src> 
        <href>http://www.baidu.com</href> 
    </bannerLeft> 
     
    <!--2.右边栏--> 
    <bannerRight> 
        <name>java</name> 
        <!--访问本地图片,注意图片路径/site/resources/images/right.jpg--> 
        <src>images/right.jpg</src> 
        <href>http://www.hao123.com</href> 
    </bannerRight> 


    <!--3.显示发布时间位置--> 
    <publishDate position="right"/> 


    <body> 
        <!--4.导航栏链接--> 
        <breadcrumbs> 
            <item name="youku" href="www.youku.com"/> 
            <item name="iqiyi" href="www.iqiyi.com"/> 
        </breadcrumbs> 


        <!--5.导航边栏--> 
        <menu name="${project.name}"> 
            <!--href-引用自定义页面,apttest.apt文件生成--> 
            <item name="apttest" href="apttest.html"/> 
        </menu> 
        <menu name="Examples"> 
            <!--href-引用自定义页面,faqtest.faq文件生成--> 
            <item name="faltest" href="faqtest.html"/> 
        </menu> 


        <!--6.ref-引用默认自动生成的报告页面--> 
        <menu ref="reports"/> 
    </body> 


    <!--7.站点皮肤:如下图与如上有区别--> 
    <skin> 
        <groupId>com.googlecode.fluido-skin</groupId> 
        <artifactId>fluido-skin</artifactId> 
        <version>1.3</version> 
    </skin> 
</project> 
src/site/fml/faqtest.fml文件(一种用来创建FAQ页面的XML文档格式) 
<?xml version="1.0" encoding="UTF-8"?> 
<faqs 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 
      http://maven.apache.org/xsd/fml-1.0.1.xsd" 
      title="fqltest title" 
      toplink="false"> 
      <part id="install"> 
        <title>title1</title> 
        <faq id="download"> 
            <question>what?</question> 
            <answer> 
                <p>answer1</p> 
                <p>answer2</p> 
            </answer> 
        </faq> 
      </part> 
</faqs> 
src/site/apt/apttest.apt文件(一种类似于维基的文档格式,用它来快速创建简单而又结构丰富的文档) 
what is apt? 
* aaaa 
* bbbb 
3.执行mvn site生成站点中,生成自定义站点如下: 
TheApache Software Foundation Version: 1.0-SNAPS I youku > check phone apt test Examples Project Documentation Project Information P roject Reports Built maven fqltest title titlel 1. what? titlel what? answerl answer2 Maven Last Published: 2016-10-20 Copyright @ 2016. All Rights Reserved.
五、国际化 
1.要正确的生成简单中文站点,首先要确保项目所有的源码,包括pom.xml、site.xml以及apt文档等,都是使用UTF-8编码保存; 
2.接下来我们配置pom.xml,配置编码格式,本地语言; 
<project> 
    ... ...  
    <!--属性,在POM的其它地方使用${属性名称}的方式引用属性--> 
    <properties> 
        <!--国际化,告诉maven-site-plugin使用UTF-8编码读取所有源码及文档--> 
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
    </properties> 


    <!--构建配置--> 
    <build> 
        <plugins> 
            <!--生成站点插件--> 
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId> 
                <artifactId>maven-site-plugin</artifactId> 
                <version>3.3</version> 
                <!--国际化定义当地语言--> 
                <configuration> 
                    <locales>zh_CN</locales> 
                </configuration> 
            </plugin> 
        </plugins> 
    </build> 
    ... ....  
</project> 
3.执行mvn site生成站点中,生成本地化站点如下:
TheApach Software Foundation : 1.0-SNAPSHOT ] youku > iqiyi check phone apttest Examples faltest 顶 目 文 0 页 目 信 息 持 缍 蘖 成 项 目 依 赖 依 赖 一 致 性 Dependency Informati 〕 n 欢 来 到 问 题 跟 Plugin Management P [ 凵 ns 项 目 团 源 代 码 库 项 目 滁 要 页 目 掘 表 maven 项 目 总 体 信 息 本 档 提 了 与 本 项 目 相 关 信 的 各 种 档 和 誕 接 的 滁 述 。 里 的 所 有 内 夻 都 是 根 本 项 目 信 生 成 的 , 自 动 生 成 逦 程 依 Maven 0 概 述 持 缍 蘖 成 项 目 依 赖 依 赖 一 致 性 Dependency Information 欢 来 到 问 题 跟 Plugin Management 项 目 团 源 代 码 库 项 目 滁 要 持 缍 蘖 成 是 以 一 定 的 频 率 和 固 定 的 皇 石 出 进 行 代 码 构 津 和 试 的 逦 程 , 里 列 出 了 所 有 的 持 缍 蘖 成 逦 程 。 一 档 列 出 了 项 目 的 依 赖 # 提 了 个 依 赖 的 相 关 信 。 本 档 提 了 个 项 目 以 及 项 目 的 子 模 块 中 所 有 依 赖 的 本 一 致 性 信 。 Thisdocumentdescribeshowtotoincludethisprojectasadependencyusingvariousdependencymanagementtools. check phone description. 是 本 项 目 中 的 问 题 苣 理 系 统 的 誕 接 。 用 户 司 以 存 里 进 行 问 题 { 战 、 特 性 、 更 清 求 阳 勺 创 津 和 查 。 This document 0 the plugins that are defined through pluginManagement. Thisdocumentliststhebuildpluginsandthereportpluginsusedbythisproject. 本 档 提 了 本 项 目 中 成 员 的 信 . 他 们 是 存 本 项 目 中 以 某 种 形 式 帥 出 了 贡 献 的 个 人 是 一 个 存 线 代 码 库 , 它 司 以 逦 № b 器 进 行 查 香 . 吡 档 列 出 了 该 项 目 其 它 的 相 关 信 Maven 最 近 更 新 : 2D16 . 10 . 20 Copyhght 2016. [ Rights Resen•ed.

你可能感兴趣的:(maven,javadoc,checkstyle,site,pmd)