概要
maven的一个很好的功能就是能以很小代价创建一个内部技术站点。 maven 2 继承了这项功能并带来了一个新的更强大的生成站点内容的功能。这篇文章将带你一步一步创建一个好的maven站点.
团队交流是项目的一个基本部分。花费时间在查找项目的技术信息上可能是代价不菲并且令人沮丧的。明显地, 拥有自己专用的web站点对每个it项目有利的。
maven站点生成器就是为此而生。以微小的努力,你就能有拥有一个专业水准、低维护成本、快速运行的web站点。maven让你生成项目的一站式信息中心, 包括:
#一般项目信息,诸如源码库, 缺陷追踪, 团队成员等
#单元测试报告及测试覆盖率报告
#使用checkstyle和pmd对代码进行自动审查
#配置和版本信息
#依赖关系
#javadocs
#源代码的html形式,建立索引和可交叉查考
#更多
maven站点被频繁地使用在开源项目中 (在资源列表有一些例子)。一个典型的项目站点包含:项目信息,大部分来自文件pom.xml;一些生成的报表(单元测试, javadocs, checkstyle 代码审查等等); 还有一项目相关的事物内容。
在这篇文章里,我们将带领你如何在很短的时间内建立起一个maven站点并使之运行。 注意: 此教程所使用的源码可在资源列表中下载。
环节1: 项目信息部分
对于一个新进人员,可能会把你的maven站点当作了解项目的第一站。并且希望在项目信息页面上了解到你这个项目组织的大概面貌。web站点的这一部分全部使用来自文件pom.xml的信息。一个缺省的pom.xml大概看起来像这样:
<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/maven-v400.xsd>
<modelversion>4.0.0</modelversion>
<groupid>com.javaworld.hotels</groupid>
<artifactid>hotelweb</artifactid>
<packaging>jar</packaging>
<version>1.0-snapshot</version>
<name>maven quick start archetype</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupid>junit</groupid>
<artifactid>junit</artifactid>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
...
<name>hotel database tutorial application</name>
<url>http://your.project.url</url>
<description>write a few paragraphs to say what your project is about.</description>
...
<issuemanagement>
<system>bugzilla</system>
<url>https://bugzilla.wakaleo.com/</url>
</issuemanagement>
...
<cimanagement>
<system>continuum</system>
<url>http://integrationserver.wakaleo.com/continuum</url>
<notifiers>
<notifier>
<type>mail</type>
<address>duke@wakaleo.com</address>
</notifier>
</notifiers>
</cimanagement>
...
<developers>
<developer>
<id>duke</id>
<name>duke java</name>
<email>duke@wakaleo.com</email>
<roles>
<role>project manager</role>
<role>architect</role>
</roles>
<organization>acme.com</organization>
<timezone>-5</timezone>
</developer>
</developers>
...
<mailinglists>
<mailinglist>
<name>hoteldatabase project mailing list</name>
<subscribe>dev-subscribe@wakaleo.com</subscribe>
<unsubscribe>dev-unsubscribe@wakaleo.com</unsubscribe>
<post>dev@wakaleo.com</post>
<archive>http://mail-archives.wakaleo.com/modmbox/dev/</archive>
</mailinglist>
</mailinglists>
...
<scm>
<connection>scm:svn:http://svn.wakaleo.com/hoteldatabase/</connection>
<developerconnection>scm:svn:http://svn.wakaleo.com/hoteldatabase/</developerconnection>
<url>http://svn.wakaleo.com/viewcvs.cgi/hoteldatabase/</url>
</scm>
<reporting>
<plugins>
<plugin>
<artifactid>maven-javadoc-plugin</artifactid>
</plugin>
<plugin>
<groupid>org.codehaus.mojo</groupid>
<artifactid>jxr-maven-plugin</artifactid>
</plugin>
</plugins>
</reporting>
<reporting>
<plugins>
...
<plugin>
<artifactid>maven-surefire-plugin</artifactid>
</plugin>
</plugins>
</reporting>
<reporting>
<plugins>
...
<plugin>
<artifactid>maven-clover-plugin</artifactid>
</plugin>
</plugins>
</reporting>
<reporting>
<plugins>
...
<plugin>
<groupid>org.apache.maven.plugins</groupid>
<artifactid>maven-pmd-plugin</artifactid>
<configuration>
<targetjdk>1.5</targetjdk>
<rulesets>
<ruleset>/rulesets/basic.xml</ruleset>
<ruleset>/rulesets/controversial.xml</ruleset>
</rulesets>
<format>xml</format>
<linkxref>true</linkxref>
<sourceencoding>utf-8</sourceencoding>
<minimumtokens>100</minimumtokens>
</configuration>
</plugin>
</plugins>
</reporting>
<?xml version="1.0" encoding="iso-8859-1"?>
<document>
<properties>
<title>hotel database tutorial application</title>
<author email="duke@wakaleo.com>duke java</author>
</properties>
<body>
<release version="current" description="current work version>
<action dev="duke java" type="add>
a new cool feature.
</action>
</release>
<release version="1.0.1" date="2005-11-18" description="release fix>
<action dev="duke java" type="add>
added a cool feature.
</action>
<action dev="duke java" type="fix" issue="1254>
fixed a nasty bug.
</action>
<action dev="duke java" type="delete>
removed a feature that nobody liked.
</action>
</release>
</body>
</document>
<reporting>
<plugins>
...
<plugin>
<groupid>org.codehaus.mojo</groupid>
<artifactid>changes-maven-plugin</artifactid>
</plugin>
<plugins>
</reporting>
<reporting>
<plugins>
...
<plugin>
<groupid>org.codehaus.mojo</groupid>
<artifactid>changelog-maven-plugin</artifactid>
</plugin>
</plugins>
</reporting>
<reporting>
<plugins>
...
<plugin>
<groupid>org.codehaus.mojo</groupid>
<artifactid>taglist-maven-plugin</artifactid>
</plugin>
<plugins>
</reporting>
<?xml version="1.0" encoding="iso-8859-1"?>
<site>
<bannerleft>
<name>hotel database</name>
<src>http://maven.apache.org/images/apache-maven-project.png</src>
<href>http://maven.apache.org/</href>
</bannerleft>
<bannerright>
<src>http://maven.apache.org/images/maven-small.gif</src>
</bannerright>
<body>
<links>
<item name="maven" href="http://maven.apache.org/"/>
<item name="apache" href="http://www.apache.org/"/>
</links>
<menu name="the hotel database project>
<item name="vision statement" href="/vision-statement.html"/>
<item name="best practices" href="/best-practices.html"/>
<item name="faqs" href="/faqs.html"/>
</menu>
${reports}
</body>
</site>
<document>
<properties>
<author email="user@company.com> the wakaleo team< /author>
<title> the hotel database vision statement< /title>
</properties>
<body>
<section name="introduction">
<p>
this application demonstrates maven 2 site generation functionalities. one of the nicer features of maven is the ability to create an internal technical web site
at very little cost. maven 2 extends this functionality, and gives you powerful new ways
to generate site content...
</p>
<subsection name="team communication">
<! --team communication is an essential part of any project. and wasting
time looking for technical project information can be costly and frustrating. clearly,
any it project will benefit from having its own dedicated technical web site. some
useful things it provides are:
<ul>
<li>online javadoc</li>
<li>quality assurance</li>
<ul>
<li>static code audits with checkstyle or pmd
<li>unit test reports</li>
</ul>
</ul>
</p>
</subsection>
</section>
</body>
</document>
-----
the hotel database vision statement
-----
the wakaleo team
-----
january 2006
introduction
one of the nicer features of maven is the ability to create an internal technical web site
at very little cost. maven 2 extends this functionality, and gives you powerful new ways
to generate site content...
* sub-section title
team communication is an essential part of any project. and wasting time looking for technical
project information can be costly and frustrating. clearly, any it project will benifit from
having its own dedicated technical web site...
* item 1
* item 2
* item 2.1
* item 2.2
<?xml version="1.0"?>
<faqs title="about the hotel database application">
<part id="about">
<faq>
<question> this is a very frequent question</question>
<answer>
<p>
thank you for asking that question, here is the answer...
</p>
</answer>
</faq>
<faq>
<question> here is another question?< /question>
<answer>
<p>
this is the answer to this question...
</p>
</answer>
</faq>
</part>
</faqs>
<distributionmanagement>
<site>
<id> website</id>
<url> scp://www.mycompany.com/www/docs/project/</url>
</site>
</distributionmanagement>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器