Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PMD exclude not working

Tags:

maven

pmd

I am trying to finetune our CI and I can't figure out how to avoid that PMD reports violations on generated code (not talking about Android R file there) in src-gen:

I used mvn help:effective-pom to verify my config, and the POM looks like I should. It point to right folder to exclude.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>${pmd-maven-plugin.version}</version>
    <configuration>
        <linkXref>false</linkXref>
        <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
        <minimumTokens>${pmd.minimum.tokens}</minimumTokens>
        <targetJdk>${pmd.target.jdk}</targetJdk>
        <excludes>
            <exclude>**/*R.java</exclude>
            <exclude>**/*Manifest.java</exclude>
            <excludeRoots>
                <excludeRoot>${basedir}/src-gen</excludeRoot>
            </excludeRoots>
        </excludes>
like image 816
Kitesurfer Avatar asked May 05 '26 19:05

Kitesurfer


1 Answers

Looking at the example (end of the page) at the PMD plugin Usage doc page suggests that the <excludeRoots> part should be directly under <configuration>, not under <excludes>.

If that does not help, maybe try <excludeRoot>**/src-gen/**</excludeRoot> instead.

like image 187
hoijui Avatar answered May 10 '26 23:05

hoijui



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!