2

所以我正在使用 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>
4

1 回答 1

4

生成的源代码通常最终(使用 maven)在 中的子目录中target/generated-sources,对于 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>

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

于 2018-07-12T21:03:50.163 回答