2016-02-25 48 views
1

我想以某種方式使用Jacoco,以便從總體覆蓋範圍中排除Sample.java class。爲了實現這個目標我已經包括在看到maven pom.xml如何從Jacoco覆蓋範圍中排除課程?

Jacoco插件<exclude>prepare-agent目標:

   <plugin> 
      <groupId>org.jacoco</groupId> 
      <artifactId>jacoco-maven-plugin</artifactId> 
      <version>0.7.1.201405082137</version> 
      <executions> 
       <execution> 
        <id>default-prepare-agent</id> 
        <goals> 
         <goal>prepare-agent</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 

神火插件:

  <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.4.3</version> 
      <configuration> 
       <excludes> 
        <exclude>**/*Sample.java</exclude> 
       </excludes> 
      </configuration> 
     </plugin> 

屬性部分:

<properties> 
    <argLine>-Dfile.encoding=ISO-8859-1</argLine> 
</properties> 
+0

的可能的複製[Maven的Jacoco配置 - 排除類/從報告中包不工作(HTTP://計算器。 com/questions/27799419/maven-jacoco-configuration-exclude-classes-packages-from-report-not-working) – Tunaki

+2

你沒有設置右插件的配置。排除應該是'jacoco-maven-plugin',但你沒有。 – Tunaki

回答

0

這是排除/包含f的正確方法或JaCoCo:

<plugins> 
     <plugin> 
      <groupId>org.jacoco</groupId> 
      <artifactId>jacoco-maven-plugin</artifactId> 
      <version>0.7.1.201405082137</version> 
      <executions> 
       <execution> 
        <id>default-prepare-agent</id> 
        <goals> 
         <goal>prepare-agent</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <excludes> 
        <exclude>**/*Sample.java</exclude> 
       </excludes> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.4.3</version> 
     </plugin> 
    </plugins> 

欲瞭解更多詳情,您可以通過這個文件: http://www.jacoco.org/jacoco/trunk/doc/prepare-agent-mojo.html

相關問題