Gradle 发行版中包含一些插件,如下列所示
There are a number of plugins included in the Gradle distribution. These are listed below.
这些插件添加了让各种语言可以在 JVM 中被编译和执行的支持。
These plugins add support for various languages which can be compiled for and executed in the JVM.
表 22.1. 语言插件 - Table 22.1. Language plugins
插件 Id Plugin Id |
自动应用 Automatically applies |
与什么一起使用 Works with |
描述 Description |
java |
java-base |
- | 向一个项目添加 Java 编译,测试和捆绑的功能。它是许多其他 Gradle 插件的基础服务。另请参阅《第7章,Java 快速入门》。 Adds Java compilation, testing and bundling capabilities to a project. It serves as the basis for many of the other Gradle plugins. See also Chapter 7, Java Quickstart. |
groovy |
java , groovy-base |
- | 添加对 Groovy 项目构建的支持。另请参阅《第九章,Groovy 快速入门》。 Adds support for building Groovy projects. See also Chapter 9, Groovy Quickstart. |
scala |
java , scala-base |
- | 添加对 Scala 项目构建的支持。 Adds support for building Scala projects. |
antlr |
java |
- | 添加对使用 Antlr 作为生成解析器的支持。 Adds support for generating parsers using Antlr. |
这些插件添加了对各种语言的支持:
These plugins add support for various languages:
表 22.2. 语言插件 - Table 22.2. Language plugins
插件 Id Plugin Id |
自动应用 Automatically applies |
与什么一起使用 Works with |
描述 Description |
assembler |
- | - | 向项目添加本地汇编语言的功能。 Adds native assembly language capabilities to a project. |
c |
- | - | 向项目添加 C语言代码编译的功能。 Adds C source compilation capabilities to a project. |
cpp |
- | - | 向项目添加 C++ 代码编译的功能。 Adds C++ source compilation capabilities to a project. |
objective-c |
- | - | 向项目中添加 Objective-C 代码编译的功能。 Adds Objective-C source compilation capabilities to a project. |
objective-cpp |
- | - | 向项目中添加 Objective-C 代码编译的功能。 Adds Objective-C++ source compilation capabilities to a project. |
windows-resources |
- | - | 添加对本地二进制文件包含 Windows 资源的支持。 Adds support for including Windows resources in native binaries. |
以下这些插件提供了一些与各种运行时技术的集成。
These plugins provide some integration with various runtime technologies.
表 22.3. 集成插件 - Table 22.3. Integration plugins
插件 Id Plugin Id |
自动应用 Automatically applies |
与什么一起使用 Works with |
描述 Description |
application |
java |
- | 添加了一些用于运行和捆绑 Java 项目的任务作为命令行应用程序。 Adds tasks for running and bundling a Java project as a command-line application. |
ear |
- | java |
添加用于构建 J2EE 应用程序的支持。 Adds support for building J2EE applications. |
jetty |
war |
- | 在构建中将你的 web 应用程序部署到内嵌的 Jetty web 容器中。另请参阅《第十章,Web 应用程序快速入门》。 Deploys your web application to a Jetty web container embedded in the build. See also Chapter 10, Web Application Quickstart. |
maven |
- | java , war |
添加将项目发布到 Maven 仓库的支持。 Adds support for publishing artifacts to Maven repositories. |
osgi |
java-base |
java |
添加构建 OSGi 包的支持。 Adds support for building OSGi bundles. |
war |
java |
- | 添加装配 web 应用程序的 WAR 文件的支持。另请参阅《第十章,Web 应用程序快速入门》。 Adds support for assembling web application WAR files. See also Chapter 10, Web Application Quickstart. |
以下这些插件提供了一些与各种运行时技术的集成。
These plugins provide some integration with various runtime technologies.
表 22.4. 试验性的集成插件 - Table 22.4. Incubating integration plugins
插件 Id Plugin Id |
自动应用 Automatically applies |
与什么一起使用 Works with |
描述 Description |
distribution |
- | - | 添加构建 ZIP 和 TAR 分发包的支持。 Adds support for building ZIP and TAR distributions. |
java-library-distribution |
java , distribution |
- | 添加构建 Java 库的 ZIP 和 TAR 分发包的支持。 Adds support for building ZIP and TAR distributions for a Java library. |
ivy-publish |
- | java , war |
这个插件提供了一个新的 DSL,用于支持发布工件到 Ivy 存储库,它改进了现有的 DSL。 This plugin provides a new DSL to support publishing artifacts to Ivy repositories, which improves on the existing DSL. |
maven-publish |
- | java , war |
这个插件提供了一个新的 DSL,用于支持发布工件到 Maven 存储库,它改进了现有的 DSL。 This plugin provides a new DSL to support publishing artifacts to Maven repositories, which improves on the existing DSL. |
这些插件为你的软件开发过程提供帮助。
These plugins provide help with your software development process.
表 22.5. 软件开发插件 - Table 22.5. Software development plugins
插件 Id Plugin Id |
自动应用 Automatically applies |
与什么一起使用 Works with |
描述 Description |
announce |
- | - | 将消息发布到你所喜欢的平台,如 Twitter 或 Growl。 Publish messages to your favourite platforms, such as Twitter or Growl. |
build-announcements |
announce | - | 在构建的生命周期中,把本地公告中有关你感兴趣的事件发送到你的桌面。 Sends local announcements to your desktop about interesting events in the build lifecycle. |
checkstyle |
java-base |
- | 对你的项目的 Java 源文件使用 Checkstyle 执行质量检查并生成报告。 Performs quality checks on your project's Java source files using Checkstyle and generates reports from these checks. |
codenarc |
groovy-base |
- | 对你的项目的 Groovy 源文件使用 CodeNarc 执行质量检查并生成报告。 Performs quality checks on your project's Groovy source files using CodeNarc and generates reports from these checks. |
eclipse |
- | java ,groovy , scala |
生成 Eclipse IDE 所用到的文件,从而使项目能够导入到 Eclipse。另请参阅《第七章,Java 快速入门》。 Generates files that are used by Eclipse IDE, thus making it possible to import the project into Eclipse. See also Chapter 7, Java Quickstart. |
eclipse-wtp |
- | ear , war |
与 eclipse 插件一样,但它还生成 eclipse WTP(Web 工具平台)的配置文件。你的 war/ear 项目在导入 eclipse 后,应配置为能在 WTP 中使用。另请参阅《第七章,Java 快速入门》。 Does the same as the eclipse plugin plus generates eclipse WTP (Web Tools Platform) configuration files. After importing to eclipse your war/ear projects should be configured to work with WTP. See also Chapter 7, Java Quickstart. |
findbugs |
java-base |
- | 对你的项目的 Java 源文件使用 FindBugs 执行质量检查并生成报告。 Performs quality checks on your project's Java source files using FindBugs and generates reports from these checks. |
idea |
- | java |
生成 Intellij IDEA IDE 所用到的文件,从而使项目能够导入到 IDEA。 Generates files that are used by Intellij IDEA IDE, thus making it possible to import the project into IDEA. |
jdepend |
java-base |
- | 使用 JDepend 对你的项目的源文件执行质量检查并生成报告。 Performs quality checks on your project's source files using JDepend and generates reports from these checks. |
pmd pmd |
java-base |
- | 对你的项目的 Java 源文件使用 PMD 执行质量检查并生成报告。 Performs quality checks on your project's Java source files using PMD and generates reports from these checks. |
project-report |
reporting-base |
- | 生成包括了关于你的 Gradle 构建的有用信息的报告。 Generates reports containing useful information about your Gradle build. |
signing |
base | - | 添加对生成的文件或工件进行数字签名的功能。 Adds the ability to digitally sign built files and artifacts. |
sonar |
- | java-base,java,jacoco java-base, java, jacoco |
提供对 Sonar 代码质量平台的集成。已经被 Provides integration with the Sonar code quality platform. Superceeded by the |
这些插件为你的软件开发过程提供帮助。
These plugins provide help with your software development process.
表 22.6. 软件开发插件 - Table 22.6. Software development plugins
插件 Id Plugin Id |
自动应用 Automatically applies |
与什么一起使用 Works with |
描述 Description |
build-dashboard |
reporting-base | - | 生成构建仪表板报告。 Generates build dashboard report. |
build-init |
wrapper | - | 添加用于初始化一个新 Gradle 构建的支持,以及处理从 Maven 构建到 Gradle 构建的转换。 Adds support for initializing a new Gradle build. Handles converting a Maven build to a Gradle build. |
cunit |
- | - | 添加用于运行 CUnit 测试的支持。 Adds support for running CUnit tests. |
jacoco |
reporting-base | java | 提供对 Java 的JaCoCo 代码覆盖率库的集成。 Provides integration with the JaCoCo code coverage library for Java. |
sonar-runner |
- | java-base,java,jacoco java-base, java, jacoco |
取代 Provides integration with the Sonar code quality platform. Supersedes the |
visual-studio |
- | 本机语言插件 native language plugins |
添加对 Visual Studio 的集成。 Adds integration with Visual Studio. |
wrapper |
- | - | 添加用于生成 Gradle wrapper 文件的 Adds a |
这些插件构成了基本构建块,其他插件都由此组装而来。它们可供您在构建文件中使用,并在此处完整列出。但是请注意,它们还没有被视为 Gradle 公共 API 的一部分。因此,这些插件都不在用户指南中记录。你可以参考它们的 API 文档来了解更多关于它们的信息。
These plugins form the basic building blocks which the other plugins are assembled from. They are available for you to use in your build files, and are listed here for completeness. However, be aware that they are not yet considered part of Gradle's public API. As such, these plugins are not documented in the user guide. You might refer to their API documentation to learn more about them.
表 22.7. 基本插件 - Table 22.7. Base plugins
插件 Id Plugin Id |
描述 Description |
base | 添加标准的生命周期任务,并为归档任务默认进行合理的配置:
Adds the standard lifecycle tasks and configures reasonable defaults for the archive tasks:
|
java-base | 对项目添加源集的概念。它不会添加任何特定的源集。 Adds the source sets concept to the project. Does not add any particular source sets. |
groovy-base | 向项目添加 Groovy 源集的概念。 Adds the Groovy source sets concept to the project. |
scala-base | 向项目添加 Scala 源集的概念。 Adds the Scala source sets concept to the project. |
reporting-base | 将一些共享的约定属性添加到项目中,它们与报告的生成有关。 Adds some shared convention properties to the project, relating to report generation. |