第二十八章. Jetty 插件

Chapter 28. The Jetty Plugin

Jetty 插件继承自 War 插件,并添加一些任务,这些任务可以让你在构建时部署你的 web 应用程序到一个 Jetty 的 web 嵌入式容器中。
The Jetty plugin extends the War plugin to add tasks which allow you to deploy your web application to a Jetty web container embedded in the build.

28.1. 用法

28.1. Usage

要使用 Jetty 的插件,请在构建脚本中包含以下语句:
To use the Jetty plugin, include in your build script:

示例 28.1. 使用 Jetty 插件
Example 28.1. Using the Jetty plugin

build.gradle

apply plugin: 'jetty'

28.2. 任务

28.2. Tasks

Jetty 插件定义了以下任务:
The Jetty plugin defines the following tasks:

Table 28.1. Jetty plugin - tasks

任务名称
Task name
依赖于
Depends on
类型
Type
描述
Description
jettyRun compile JettyRun 启动 Jetty 实例并将部署上 exploded web 应用程序。
Starts a Jetty instance and deploys the exploded web application to it.
jettyRunWar war JettyRunWar 启动 Jetty 实例并将部署上 WAR 包。
Starts a Jetty instance and deploys the WAR to it.
jettyStop - JettyStop 停止 Jetty 实例。
Stops the Jetty instance.

图 28.1. Jetty 插件 - tasks
Figure 28.1. Jetty plugin - tasks

Jetty plugin - tasks

28.3. 项目布局

28.3. Project layout

Jetty 插件使用 和 War 插件相同的布局。
The Jetty plugin uses the same layout as the War plugin.

28.4. 依赖管理

28.4. Dependency management

Jetty 插件并不定义任何依赖配置。
The Jetty plugin does not define any dependency configurations.

28.5. 公约属性

28.5. Convention properties

Jetty 插件定义了下列公约属性:
The Jetty plugin defines the following convention properties:

表 28.2. Jetty插件 - 属性
Table 28.2. Jetty plugin - properties

属性名称
Property name
类型
Type
默认值
Default value
描述
Description
contextPath String WAR 文件的base name
WAR file base name
在 Jetty 容器里面的应用程序部署位置。
The application deployment location within the Jetty container.
httpPort Integer 8080 Jetty 监听 HTTP 请求的 TCP 端口。
The TCP port which Jetty should listen for HTTP requests on.
stopPort Integer null Jetty 监听 admin 请求的 TCP 端口。
The TCP port which Jetty should listen for admin requests on.
stopKey String null 当需要请求停止时,传递给 Jetty 的key。
The key to pass to Jetty when requesting it to stop.

这些属性都由一个 JettyPluginConvention 公约对象提供。
These properties are provided by a JettyPluginConvention convention object.