The Maven Site Plugin – Maven网站插件

最后修改: 2018年 4月 19日

中文/混合/英文(键盘快捷键:t)

1. Overview

1.概述

This tutorial introduces the site plugin, one of the core plugins of the Maven build tool.

本教程介绍了site插件,这是Maven构建工具的核心插件之一。

For an overview of the other core plugins, refer to this tutorial.

关于其他核心插件的概述,请参阅本教程

2. Plugin Goals

2.插件目标

The Maven site lifecycle has two phases bound to goals of the site plugin by default: the site phase is bound to the site goal, and the site-deploy phase is bound to the deploy goal.

Maven的site生命周期有两个阶段,默认与site插件的目标绑定:site阶段与site目标绑定,而site-deploy阶段与deploy目标绑定。

Here are the descriptions of those goals:

以下是对这些目标的描述。

  • site – generate a site for a single project; the generated site only shows information about the artifacts specified in the POM
  • deploy – deploy the generated site to the URL specified in the distributionManagement element of the POM

In addition to site and deploy, the site plugin has several other goals to customize the content of the generated files and to control the deployment process.

除了sitedeploysite插件还有其他几个目标,以定制生成文件的内容并控制部署过程。

3. Goal Execution

3.目标的执行

We can use this plugin without adding it to the POM as the super POM already includes it.

我们可以使用这个插件,而不需要把它添加到POM中,因为超级POM已经包括了它。

To generate a site, just run mvn site:site or mvn site.

要生成一个网站,只需运行mvn site:sitemvn site

To view the generated site on a local machine, run mvn site:run. This command will deploy the site to a Jetty web server at the address localhost:8080.

要在本地机器上查看生成的网站,运行mvn site:run。该命令将把网站部署到地址为localhost:8080的Jetty网络服务器上。

The run goal of this plugin isn’t implicitly bound to a phase in the site lifecycle, hence we need to call it directly.

这个插件的run目标并没有隐含地与网站生命周期的某个阶段绑定,因此我们需要直接调用它。

If we want to stop the server, we can simply hit Ctrl + C.

如果我们想停止服务器,我们可以简单地点击Ctrl + C

4. Conclusion

4.结论

This article covered the site plugin and how to execute its goals.

这篇文章涵盖了site插件以及如何执行其目标。

We can find more information about this plugin on the Maven website.

我们可以在Maven网站上找到关于这个插件的更多信息。

Next »

Guide to the Core Maven Plugins

« Previous

The Maven Verifier Plugin