在 pmd 中排除不起作用
Exclude in pmd not working
我无法对 PMD 进行排除。我需要排除位于以下目录结构中的 generated-sources 文件夹:
mainProject>subProject>target>generated-sources.
我试过如下所示的规则集:
<exclude-pattern>.*/generated-sources/*.java</exclude-pattern>
<exclude-pattern>.*/generated-sources/.*</exclude-pattern>
我也浏览了他们的文档和其他堆栈溢出链接,但似乎没有任何帮助。我尝试使用 maven-pmd-plugin 3.1 和 3.6 版本。
尝试了其他选项:
<!-- <excludeRoots>
<excludeRoot>target/generated-sources/**</excludeRoot>
</excludeRoots> -->
<!-- <excludes>
<exclude>target/generated-sources/*.*</exclude>
</excludes> -->
<!-- <excludeRoots>
<excludeRoot>target/generated-sources/**</excludeRoot>
</excludeRoots> -->
<!-- <excludes>
<exclude>${basedir}/target/generated-sources/*.java</exclude>
</excludes> -->
<!-- <excludeRoots>
<excludeRoot>${basedir}/target/generated-sources/**</excludeRoot>
</excludeRoots> -->
<!-- <excludes>
<exclude>**/generated-sources/**/*.java</exclude>
</excludes> -->
<excludeRoots>
<excludeRoot>target/generated-sources</excludeRoot>
</excludeRoots>
所有这些更改都在父 POM 中完成。
您可以使用 excludeRoots
参数来做到这一点。这使得能够从 PMD 报告和后续检查中排除源目录。 Maven subProject
的示例配置为:
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.6</version>
<configuration>
<excludeRoots>
<excludeRoot>target/generated-sources</excludeRoot>
</excludeRoots>
</configuration>
</plugin>
在您的子 pom 中,excludeRoots 需要与 compileSourceRoots 中列出的完整文件夹名称相匹配,例如
[DEBUG] (f) compileSourceRoots = [project/src/main/java, project/target/generated-sources/antlr4, project/target/generated-sources/annotations]
[调试] (f) excludeRoots = [project/target/generated-sources/antlr4, project/target/generated-sources/annotations]
子项中的插件定义看起来像
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<excludeRoots>
<excludeRoot>target/generated-sources/antlr4</excludeRoot>
<excludeRoot>target/generated-sources/annotations</excludeRoot>
</excludeRoots>
</configuration>
</plugin>
我无法对 PMD 进行排除。我需要排除位于以下目录结构中的 generated-sources 文件夹:
mainProject>subProject>target>generated-sources.
我试过如下所示的规则集:
<exclude-pattern>.*/generated-sources/*.java</exclude-pattern>
<exclude-pattern>.*/generated-sources/.*</exclude-pattern>
我也浏览了他们的文档和其他堆栈溢出链接,但似乎没有任何帮助。我尝试使用 maven-pmd-plugin 3.1 和 3.6 版本。
尝试了其他选项:
<!-- <excludeRoots>
<excludeRoot>target/generated-sources/**</excludeRoot>
</excludeRoots> -->
<!-- <excludes>
<exclude>target/generated-sources/*.*</exclude>
</excludes> -->
<!-- <excludeRoots>
<excludeRoot>target/generated-sources/**</excludeRoot>
</excludeRoots> -->
<!-- <excludes>
<exclude>${basedir}/target/generated-sources/*.java</exclude>
</excludes> -->
<!-- <excludeRoots>
<excludeRoot>${basedir}/target/generated-sources/**</excludeRoot>
</excludeRoots> -->
<!-- <excludes>
<exclude>**/generated-sources/**/*.java</exclude>
</excludes> -->
<excludeRoots>
<excludeRoot>target/generated-sources</excludeRoot>
</excludeRoots>
所有这些更改都在父 POM 中完成。
您可以使用 excludeRoots
参数来做到这一点。这使得能够从 PMD 报告和后续检查中排除源目录。 Maven subProject
的示例配置为:
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.6</version>
<configuration>
<excludeRoots>
<excludeRoot>target/generated-sources</excludeRoot>
</excludeRoots>
</configuration>
</plugin>
在您的子 pom 中,excludeRoots 需要与 compileSourceRoots 中列出的完整文件夹名称相匹配,例如
[DEBUG] (f) compileSourceRoots = [project/src/main/java, project/target/generated-sources/antlr4, project/target/generated-sources/annotations]
[调试] (f) excludeRoots = [project/target/generated-sources/antlr4, project/target/generated-sources/annotations]
子项中的插件定义看起来像
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<excludeRoots>
<excludeRoot>target/generated-sources/antlr4</excludeRoot>
<excludeRoot>target/generated-sources/annotations</excludeRoot>
</excludeRoots>
</configuration>
</plugin>