用法

本文档旨在提供使用 Maven DOCCK 插件的说明。为了使这个讨论有用,涵盖两个主题至关重要:配置项目的pom.xml以在每次构建期间运行插件以及从命令行使用插件。

在pom.xml中配置插件

每次构建项目时,您都可以在pom.xml中使用以下配置来运行 DOCCK 插件。

<project>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-docck-plugin</artifactId>
        <version>1.1</version>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

从命令行使用插件

DOCCK 插件很容易从命令行执行,因为它可以在没有任何参数配置的情况下运行。

要在项目上运行 DOCCK 插件,请键入:

mvn docck:check

样本输出

在没有文档错误的情况下运行

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'docck'.
[INFO] ----------------------------------------------------------------------------
[INFO] Building Mojo Project
[INFO]    task-segment: [docck:check] (aggregator-style)
[INFO] ----------------------------------------------------------------------------
[INFO] [docck:check]
[INFO] Checking project: Mojo Project
[INFO] Using 2 extractors.
[INFO] Applying extractor for language: java
[INFO] Extractor for language: java found 1 mojo descriptors.
[INFO] Applying extractor for language: bsh
[INFO] Extractor for language: bsh found 0 mojo descriptors.
[INFO] No documentation errors were found.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Mon Jun 19 16:06:25 CST 2006
[INFO] Final Memory: 3M/7M
[INFO] ------------------------------------------------------------------------

运行文档错误

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'docck'.
[INFO] ----------------------------------------------------------------------------
[INFO] Building Mojo Project
[INFO]    task-segment: [docck:check] (aggregator-style)
[INFO] ----------------------------------------------------------------------------
[INFO] [docck:check]
[INFO] Checking project: Mojo Project
[INFO] Using 2 extractors.
[INFO] Applying extractor for language: java
[INFO] Extractor for language: java found 1 mojo descriptors.
[INFO] Applying extractor for language: bsh
[INFO] Extractor for language: bsh found 0 mojo descriptors.
[ERROR] The following documentation problems were found:

o Maven Documentation Checker Plugin (3 errors)
  [ERROR] There is no 'index' file in your site directory (in apt|html|xml[.vm] format).
  [ERROR] There are no example files in your site directory (in apt|html|xml[.vm] format). They should either be called 'example*.(apt|html|xml)[.vm]' or they should be located in the 'examples' directory.
  [ERROR] Parameter: 'mojoParameter' in mojo: 'check' is missing a description.

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Documentation problems were found. Please see the console output above for more information.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Mon Jun 19 15:54:58 CST 2006
[INFO] Final Memory: 3M/7M
[INFO] ------------------------------------------------------------------------