繁体   English   中英

如何获取PMD Maven插件以跳过生成的源代码?

[英]How to get PMD maven plugin to skip generated source code?

所以我正在使用maven-plugin-plugin创建一个maven插件。 maven-plugin-plugin中的HelpMojo生成一个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>

生成的源通常以target/generated-sources的子目录结尾(使用maven),对于maven-plugin-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>

还有一个基于文件的排除选项。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM