简体   繁体   English

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

[英]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>

There is also a file based exclude option. 还有一个基于文件的排除选项。

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

相关问题 如何从源代码触发Eclipse PMD插件功能? - How to trigger an Eclipse PMD plugin feature from source code? 如何使用m2e-code-quality在maven-pmd插件中使用声纳PMD永久链接? - How to use sonar pmd permalink in maven-pmd plugin using m2e-code-quality? 如何为 maven pmd 插件下载 pmd_ruleset 文件? - How to download pmd_ruleset file for maven pmd plugin? 多次执行 PMD maven 插件 - multiple executions of PMD maven plugin 使用Maven PMD插件生成摘要 - Generate a summary with the Maven PMD plugin 如何自定义maven-java-doc插件,即只有已更改的Java源代码部分将在完整的生成的Java docfile中更新? - How to customize maven-java-doc plugin, that only changed java source code sections will be updated in the complete generated java docfiles? JOOQ Maven插件-生成的源文件的编码 - JOOQ Maven plugin - encoding of generated source files 如何获取Groovy生成的java源代码 - How to get the Groovy generated java source code Maven - 如何在使用 maven-source-plugin 生成的.jar 文件中包含 jsp 文件 - Maven - How can I include jsp files in the .jar file generated using maven-source-plugin 如何让 lombok 生成的源在 eclipse/maven 中可见? - How to get lombok generated source to be visible in eclipse/maven?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM