PMD - How to exclude files from violation check

Deadly 提交于 2019-12-10 23:29:54

问题


We're checking our code using the PMD 'check' goal that is bound to the 'verify' life cycle. (http://maven.apache.org/plugins/maven-pmd-plugin/examples/violationChecking.html)

For the 'pmd' goal you can add 'excludes' and 'excludeRoots' but not for the 'check' goal.

How does one exclude eg. generated sources directories?


回答1:


You need to do the pmd:pmd first and afterwards do a pmd:check. You can configure that simply by using. Bind that to a particular lifecycle-phase which is before verify. For example into package or pre-integration-test phase.

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>2.7.1</version>
    <executions>
      <execution>
        <goals>
          <goal>pmd</goal>
          <goal>check</goal>
        </goals>
        <phase>package</phase>
      </execution>
    </executions>
  </plugin>

The check goals (check, cpd-check are exactly intended to fail a build if there are some violations. So you can define some exceptions for the pmd goal which folders should be included/excluded.



来源:https://stackoverflow.com/questions/9769641/pmd-how-to-exclude-files-from-violation-check

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!