所以我使用maven- plugin -plugin创建了一个maven插件。maven- HelpMojo -plugin中的插件生成一个java源文件。
不幸的是,PMD发现了这一点并对此进行了抱怨。有没有办法让PMD只忽略单个源文件?谢谢!
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>
发布于 2018-07-13 05:03:50
生成的源代码通常(使用maven)放在插件中的子目录中,对于maven- target/generated-sources
-plugin,该子目录为target/generated-sources/plugin
。
您可以使用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>
还有一个基于文件的exclude选项。
https://stackoverflow.com/questions/51291700
复制相似问题