无法生成多格式 PMD 报告

Unable to generate PMD Reports in multi-format

我想使用 maven 以 .csv 和 .xml 格式生成 PMD 报告。我编辑了我的 pom.xml 如下:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <formats>
            <format>csv</format>
            <format>xml</format>
        </formats>
        <rulesets>
            <ruleset>../PMD_RuleSet/PMDRules.xml</ruleset>
        </rulesets>
    </configuration>
</plugin>

如果我遵循正确的配置,请告诉我。 谢谢

<formats> not exist :

尝试:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>3.1</version>
        <configuration> 
            <rulesets>
                <ruleset>../PMD_RuleSet/PMDRules.xml</ruleset>
            </rulesets>
        </configuration>
    </plugin>

    Execute : mvn clean pmd:pmd -Dformat=csv
    Execute : mvn clean pmd:pmd -Dformat=xml

试试这个:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>3.5</version> 
     <executions>
      <execution>
         <id>default-pmd</id>
        <goals>
          <goal>pmd</goal>
        </goals>
        <configuration>
          <format>xml</format>
        </configuration>
      </execution>
      <execution>
        <id>format_csv</id>
        <goals>
          <goal>pmd or check or cpd-check</goal>
        </goals>
        <configuration>
          <format>csv</format>
        </configuration>
      </execution>
    </executions>  
</plugin>