abb*_*gr8 3 java build pmd pom.xml maven
我在我的pom.xml中有以下配置来检查PMD违规:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.version}</version>
<configuration>
<linkXRef>true</linkXRef>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.7</targetJdk>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当我使用该命令运行构建时mvn clean install,PMD检查作为构建过程的最后一步运行.相反,我希望PMD检查作为构建的第一步运行.
有谁知道我怎么能做到这一点?
将phase元素添加到POM中.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.version}</version>
<configuration>
<linkXRef>true</linkXRef>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.7</targetJdk>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
验证阶段是maven生命周期的第一阶段:http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
感谢 @JamesB 和 @PetrMensik 的回答,让我了解POM 中的阶段元素。它帮助我解决了我的问题。我最终决定这样做:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.version}</version>
<configuration>
<linkXRef>true</linkXRef>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.7</targetJdk>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我使用了阶段:compile,原因是我的项目中有大量测试,需要花费大量时间来执行。而且,等待这些测试完成并在所有测试结束时收到有关 PMD 违规的通知,这非常令人恼火。在测试之前我需要一些东西。因此,我决定编译。
欢迎进一步提出建议。:)
| 归档时间: |
|
| 查看次数: |
3941 次 |
| 最近记录: |