第22章 Standard Gradle plugins 标准 Gradle 插件
最后更新于:2022-04-01 02:33:10
Gradle 发布包包含了很多插件,如下:
## [](https://github.com/waylau/Gradle-2-User-Guide/blob/master/Chapter%2022.%20Standard%20Gradle%20plugins%20%E6%A0%87%E5%87%86%20Gradle%20%E6%8F%92%E4%BB%B6.md#221-language-plugins-语言类插件)22.1\. Language plugins 语言类插件
这些插件添加各种语言可以被编译为在JVM中执行的支持。
Table 22.1\. Language plugins
| Plugin Id | Automatically applies | Works with | Description |
| --- | --- | --- | --- |
| [`java`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/java_plugin.html) | `java-base` | - | 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*](https://github.com/waylau/Gradle-2-User-Guide/blob/master/tutorial_java_projects.html). |
| [`groovy`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/groovy_plugin.html) | `java`,`groovy-base` | - | Adds support for building Groovy projects. See also [Chapter 9, *Groovy Quickstart*](https://github.com/waylau/Gradle-2-User-Guide/blob/master/tutorial_groovy_projects.html). |
| [`scala`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/scala_plugin.html) | `java`,`scala-base` | - | Adds support for building Scala projects. |
| [`antlr`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/antlr_plugin.html) | `java` | - | Adds support for generating parsers using [Antlr](http://www.antlr.org/). |
## [](https://github.com/waylau/Gradle-2-User-Guide/blob/master/Chapter%2022.%20Standard%20Gradle%20plugins%20%E6%A0%87%E5%87%86%20Gradle%20%E6%8F%92%E4%BB%B6.md#222-incubating-language-plugins-孵化中的语言插件)22.2\. Incubating language plugins 孵化中的语言插件
Table 22.2\. Language plugins
| Plugin Id | Automatically applies | Works with | Description |
| --- | --- | --- | --- |
| [`assembler`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/nativeBinaries.html) | - | - | Adds native assembly language capabilities to a project. |
| [`c`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/nativeBinaries.html) | - | - | Adds C source compilation capabilities to a project. |
| [`cpp`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/nativeBinaries.html) | - | - | Adds C++ source compilation capabilities to a project. |
| [`objective-c`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/nativeBinaries.html) | - | - | Adds Objective-C source compilation capabilities to a project. |
| [`objective-cpp`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/nativeBinaries.html) | - | - | Adds Objective-C++ source compilation capabilities to a project. |
| [`windows-resources`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/nativeBinaries.html) | - | - | Adds support for including Windows resources in native binaries. |
## [](https://github.com/waylau/Gradle-2-User-Guide/blob/master/Chapter%2022.%20Standard%20Gradle%20plugins%20%E6%A0%87%E5%87%86%20Gradle%20%E6%8F%92%E4%BB%B6.md#223-integration-plugins-集成插件)22.3\. Integration plugins 集成插件
这些插件提供一些集成各种运行技术。
Table 22.3\. Integration plugins
| Plugin Id | Automatically applies | Works with | Description |
| --- | --- | --- | --- |
| [`application`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/application_plugin.html) | `java` | - | Adds tasks for running and bundling a Java project as a command-line application.|
| [`ear`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/ear_plugin.html) | - | `java` | Adds support for building J2EE applications. |
| [`jetty`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/jetty_plugin.html) | `war` | - | Deploys your web application to a Jetty web container embedded in the build. See also [Chapter 10, *Web Application Quickstart*](https://github.com/waylau/Gradle-2-User-Guide/blob/master/web_project_tutorial.html). |
| [`maven`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/maven_plugin.html) | - | `java`,`war` | Adds support for publishing artifacts to Maven repositories. |
| [`osgi`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/osgi_plugin.html) | `java-base` | `java` | Adds support for building OSGi bundles. |
| [`war`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/war_plugin.html) | `java` | - | Adds support for assembling web application WAR files. See also[Chapter 10, *Web Application Quickstart*](https://github.com/waylau/Gradle-2-User-Guide/blob/master/web_project_tutorial.html). |
## [](https://github.com/waylau/Gradle-2-User-Guide/blob/master/Chapter%2022.%20Standard%20Gradle%20plugins%20%E6%A0%87%E5%87%86%20Gradle%20%E6%8F%92%E4%BB%B6.md#224-incubating-integration-plugins-孵化中的集成插件)22.4\. Incubating integration plugins 孵化中的集成插件
这些插件提供一些集成各种运行技术。
Table 22.4\. Incubating integration plugins
| Plugin Id | Automatically applies | Works with | Description |
| --- | --- | --- | --- |
| [`distribution`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/distribution_plugin.html) | - | - | Adds support for building ZIP and TAR distributions. |
| [`java-library-distribution`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/javaLibraryDistribution_plugin.html) | `java`,`distribution` | - | Adds support for building ZIP and TAR distributions for a Java library. |
| [`ivy-publish`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/publishing_ivy.html) | - | `java`,`war` | This plugin provides a new DSL to support publishing artifacts to Ivy repositories, which improves on the existing DSL. |
| [`maven-publish`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/publishing_maven.html) | - | `java`,`war` | This plugin provides a new DSL to support publishing artifacts to Maven repositories, which improves on the existing DSL. |
## [](https://github.com/waylau/Gradle-2-User-Guide/blob/master/Chapter%2022.%20Standard%20Gradle%20plugins%20%E6%A0%87%E5%87%86%20Gradle%20%E6%8F%92%E4%BB%B6.md#225-software-development-plugins-软件开发插件)22.5\. Software development plugins 软件开发插件
Table 22.5\. Software development plugins
| Plugin Id | Automatically applies | Works with | Description |
| --- | --- | --- | --- |
| [`announce`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/announce_plugin.html) | - | - | Publish messages to your favourite platforms, such as Twitter or Growl. |
| [`build-announcements`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/build_announcements_plugin.html) | announce | - | Sends local announcements to your desktop about interesting events in the build lifecycle. |
| [`checkstyle`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/checkstyle_plugin.html) | `java-base` | - | Performs quality checks on your project's Java source files using [Checkstyle](http://checkstyle.sourceforge.net/index.html) and generates reports from these checks. |
| [`codenarc`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/codenarc_plugin.html) | `groovy-base` | - | Performs quality checks on your project's Groovy source files using [CodeNarc](http://codenarc.sourceforge.net/index.html) and generates reports from these checks. |
| [`eclipse`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/eclipse_plugin.html) | - | `java`,`groovy`,`scala` | Generates files that are used by [Eclipse IDE](http://eclipse.org/), thus making it possible to import the project into Eclipse. See also [Chapter 7,*Java Quickstart*](https://github.com/waylau/Gradle-2-User-Guide/blob/master/tutorial_java_projects.html). |
| [`eclipse-wtp`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/eclipse_plugin.html) | - | `ear`, `war` | 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*](https://github.com/waylau/Gradle-2-User-Guide/blob/master/tutorial_java_projects.html). |
| [`findbugs`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/findbugs_plugin.html) | `java-base` | - | Performs quality checks on your project's Java source files using [FindBugs](http://findbugs.sourceforge.net/) and generates reports from these checks. |
| [`idea`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/idea_plugin.html) | - | `java` | Generates files that are used by [Intellij IDEA IDE](http://www.jetbrains.com/idea/index.html), thus making it possible to import the project into IDEA. |
| [`jdepend`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/jdepend_plugin.html) | `java-base` | - | Performs quality checks on your project's source files using[JDepend](http://clarkware.com/software/JDepend.html) and generates reports from these checks. |
| [`pmd`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/pmd_plugin.html) | `java-base` | - | Performs quality checks on your project's Java source files using [PMD](http://pmd.sourceforge.net/) and generates reports from these checks. |
| [`project-report`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/project_reports_plugin.html) | `reporting-base` | - | Generates reports containing useful information about your Gradle build. |
| [`signing`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/signing_plugin.html) | base | - | Adds the ability to digitally sign built files and artifacts. |
| [`sonar`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/sonar_plugin.html) | - | java-base, java, jacoco | Provides integration with the [Sonar](http://www.sonarsource.org/) code quality platform. Superceeded by the [`sonar-runner`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/sonar_runner_plugin.html) plugin. |
## [](https://github.com/waylau/Gradle-2-User-Guide/blob/master/Chapter%2022.%20Standard%20Gradle%20plugins%20%E6%A0%87%E5%87%86%20Gradle%20%E6%8F%92%E4%BB%B6.md#226-incubating-software-development-plugins-孵化中的软件开发插件)22.6\. Incubating software development plugins 孵化中的软件开发插件
Table 22.6\. Software development plugins
| Plugin Id | Automatically applies | Works with | Description |
| --- | --- | --- | --- |
| [`build-dashboard`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/buildDashboard_plugin.html) | reporting-base | - | Generates build dashboard report. |
| [`build-init`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/build_init_plugin.html) | wrapper | - | Adds support for initializing a new Gradle build. Handles converting a Maven build to a Gradle build. |
| [`cunit`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/nativeBinaries.html) | - | - | Adds support for running [CUnit](http://cunit.sourceforge.net/) tests. |
| [`jacoco`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/jacoco_plugin.html) | reporting-base | java | Provides integration with the [JaCoCo](http://www.eclemma.org/jacoco/) code coverage library for Java. |
| [`sonar-runner`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/sonar_runner_plugin.html) | - | java-base, java, jacoco |Provides integration with the [Sonar](http://www.sonarsource.org/) code quality platform. Supersedes the [`sonar`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/sonar_plugin.html) plugin. |
| [`visual-studio`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/nativeBinaries.html) | - | native language plugins | Adds integration with Visual Studio. |
| [`wrapper`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/wrapper_plugin.html) | - | - | Adds a [`Wrapper`](https://github.com/waylau/Gradle-2-User-Guide/blob/dsl/org.gradle.api.tasks.wrapper.Wrapper.html) task for generating Gradle wrapper files. |
| [`java-gradle-plugin`](https://github.com/waylau/Gradle-2-User-Guide/blob/master/javaGradle_plugin.html) | java | | Assists with development of Gradle plugins by providing standard plugin build configuration and validation. |
## 22.7\. Base plugins 基本插件
这些插件形成基本构建块,用来提供给其他插件组装。它们可以被使用在你的构建文件,并列出的完整性。然而,要注意他们还没有考虑 Gradle 的公共API的一部分。因此,这些插件都不能列在用户指南文件中。你可以参考他们的API文档来了解他们。
Table 22.7\. Base plugins
| 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 | Adds the Groovy source sets concept to the project.|
| scala-base | Adds the Scala source sets concept to the project. |
| reporting-base | Adds some shared convention properties to the project, relating to report generation. |
## [](https://github.com/waylau/Gradle-2-User-Guide/blob/master/Chapter%2022.%20Standard%20Gradle%20plugins%20%E6%A0%87%E5%87%86%20Gradle%20%E6%8F%92%E4%BB%B6.md#228-third-party-plugins-第三方插件)22.8\. Third party plugins 第三方插件
可以从[这里](http://plugins.gradle.org/)看到外部的插件