2015-11-03 85 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