本文禁止w3cschool转载!
翻译项目请关注Github上的地址:https://github.com/msdx/gradledoc 。
本文翻译所在分支:https://github.com/msdx/gradledoc/tree/2.0 。
更好的阅读体验请访问:http://gradledoc.githang.com/2.0/userguide/userguide.html 。
另外,Android 手机用户可通过我写的一个程序浏览文档,带缓存功能的,目前0.6.1版本兼容 Android 4.0.3以上系统,项目地址如下:
https://github.com/msdx/gradle-doc-apk
翻译不易,本文采用 CC BY-NC-SA 4.0 许可协议,转载请务必署名及注明本文在CSDN博客上的出处:
https://blog.csdn.net/maosidiaoxian/article/details/86637092
关于我对Gradle的翻译,以Github上的项目及http://gradledoc.githang.com 上的文档为准。如发现翻译有误的地方,将首先在以上两个地方更新。因时间精力问题,博客中发表的译文基本不会同步修改。
第三十三章. PMD 插件
Chapter 33. The PMD Plugin
PMD 插件使用 PMD 对项目的 Java 源文件执行质量检查,并从这些检查中生成报告。
The PMD plugin performs quality checks on your project's Java source files using PMD and generates reports from these checks.
33.1. 用法
33.1. Usage
要使用 PMD 插件,请在构建脚本中包含:
To use the PMD plugin, include in your build script:
示例 33.1. 使用 PMD 插件 - Example 33.1. Using the PMD plugin
build.gradle
apply plugin: 'pmd'
该插件向项目添加了许多执行质量检查的任务。你可以通过运行 gradle check
来执行这些检查。
The plugin adds a number of tasks to the project that perform the quality checks. You can execute the checks by running gradle check
.
33.2. 任务
33.2. Tasks
PMD 插件将以下任务添加到项目中:
The PMD plugin adds the following tasks to the project:
表 33.1. PMD 插件——任务 - Table 33.1. PMD plugin - tasks
任务名称 Task name | 依赖于 Depends on | 类型 Type | 描述 Description |
pmdMain | - | Pmd | 针对 Java 生产源文件运行 PMD。 Runs PMD against the production Java source files. |
pmdTest | - | Pmd | 针对 Java 测试源文件运行 PMD。 Runs PMD against the test Java source files. |
pmd | - | Pmd | 针对给定源集的 Java 源文件运行 PMD。 Runs PMD against the given source set's Java source files. |
PMD 插件向 Java 插件所定义的任务添加了以下的依赖。
The PMD plugin adds the following dependencies to tasks defined by the Java plugin.
表 33.2. PMD 插件——附加的任务依赖 - Table 33.2. PMD plugin - additional task dependencies
任务名称 Task name | 依赖于 Depends on |
check | 所有的 PMD 任务,包括 pmdMain 和 pmdTest 。All PMD tasks, including pmdMain and pmdTest . |
33.3. 依赖管理
33.3. Dependency management
PMD 插件添加了下列的依赖配置:
The PMD plugin adds the following dependency configurations:
表33.3. PMD 插件——依赖配置 - Table 33.3. PMD plugin - dependency configurations
名称 Name | 意义 Meaning |
pmd | 要使用的 PMD 库 The PMD libraries to use |
33.4. 配置
33.4. Configuration
请参阅 PmdExtension
。
See PmdExtension
.