2015-11-03 84 views
0

我想用.csv和.xml格式的maven生成PMD报告。我编辑我的pom.xml如下:无法生成多格式的PMD报告

<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> 

请让我知道,如果我遵循正确的配置。 感谢

回答

1
<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 
+0

我要生成无论是在XML和CSV报告一起。会有可能吗? – Ayush

+0

目前还不清楚这个答案是暗示读者应该做什么。 “格式不存在”是什么意思?这种XML格式是无效的,还是在OP的XML中缺少,实际上是必需的?你的“执行”部分是它们出现的XML块的一部分吗?或者应该是一个单独的格式化块? – halfer

0

试试这个:

<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> 
+0

即使这不起作用。它给出了一个错误 – Ayush

+0

在处理POM时遇到了一些问题: [错误]'build.plugins.plugin [org.apache.maven.plugins:maven-pmd-plugin] .executions.execution.id'必须是唯一的但发现重复的执行id为default @ line 250,第17列 – Ayush