[英]How to get PMD maven plugin to skip generated source code?
So I'm creating a maven plugin using the maven-plugin-plugin. 所以我正在使用maven-plugin-plugin创建一个maven插件。 The HelpMojo in maven-plugin-plugin generates a java source file.
maven-plugin-plugin中的HelpMojo生成一个Java源文件。
Unfortunately, PMD is picking this up and complaining about it. 不幸的是,PMD正在对此进行投诉。 Is there a way to have PMD ignore just a single source file?
有没有一种方法可以让PMD忽略单个源文件? Thanks!
谢谢!
Maven PMD Configuration: Maven PMD配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<executions>
<execution>
<id>pmd-verify</id>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
<configuration>
<printFailingErrors>true</printFailingErrors>
</configuration>
</execution>
</executions>
</plugin>
Generated sources usually end up (with maven) in a subdirectory in target/generated-sources
, for the maven-plugin-plugin it's target/generated-sources/plugin
. 生成的源通常以
target/generated-sources
的子目录结尾(使用maven),对于maven-plugin-plugin来说,它是target/generated-sources/plugin
。
You can exclude these complete directories with excludeRoots , eg 您可以使用excludeRoots排除这些完整目录,例如
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<executions>
<execution>
<id>pmd-verify</id>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
<configuration>
<printFailingErrors>true</printFailingErrors>
<excludeRoots>
<excludeRoot>target/generated-sources/plugin</excludeRoot>
</excludeRoots>
</configuration>
</execution>
</executions>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.