我正在使用Jacoco Maven插件版本0.8.1(使用Java 8 / Maven 3.1.0)。 无法让Jacoco使用路径排除。 我想排除这些包:
my.package.model
my.package.exception
我尝试了什么:
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>my.package.model</exclude>
<exclude>my.package.exception</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<configuration>
<excludes>
<exclude>my.package.model</exclude>
<exclude>my.package.exception</exclude>
</excludes>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
并且(对于excludes
部分):
<excludes>
<exclude>my.package.model**</exclude>
<exclude>my.package.exception**</exclude>
</excludes>
<excludes>
<exclude>my/package/model/**/*</exclude>
<exclude>my/package/exception/**/*</exclude>
</excludes>
<excludes>
<exclude>*/my/package/model/**/*</exclude>
<exclude>*/my/package/exception/**/*</exclude>
</excludes>
<excludes>
<exclude>**/my/package/model/**/*</exclude>
<exclude>**/my/package/exception/**/*</exclude>
</excludes>
<excludes>
<exclude>**/my/package/model/**</exclude>
<exclude>**/my/package/exception/**</exclude>
</excludes>
<excludes>
<exclude>**/my/package/model/*</exclude>
<exclude>**/my/package/exception/*</exclude>
</excludes>
<excludes>
<exclude>**/model/*</exclude>
<exclude>**/exception/*</exclude>
</excludes>
<excludes>
<exclude>**/model**</exclude>
<exclude>**/exception**</exclude>
</excludes>
无法从最终报告中删除这些软件包......令人沮丧。
我看了:
没什么用。
有什么想法吗?
答案 0 :(得分:2)
我有,并且它有效(请注意excludes
在execution/configuration
,并且所有内容都在pluginManagement
):
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/integration-coverage-reports/jacoco-it.exec</destFile>
<excludes>
<exclude>weblogic/*</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/integration-coverage-reports/jacoco-it.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
<excludes>
<exclude>my/company/package/db/entity/**/*.class</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
答案 1 :(得分:0)
根据您共享的示例,POM文件中的此更改应该起作用:
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>my/package/model/**/*.class</exclude>
<exclude>my/package/exception/**/*.class</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<configuration>
<excludes>
<exclude>my/package/model/**/*.class</exclude>
<exclude>my/package/exception/**/*.class</exclude>
</excludes>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
我通常将prepare-agent
目标和report
目标放在同一个插件中。这有助于我将排除包仅放在一个部分下。这是我的pom文件的外观:
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<configuration>
<excludes>
<exclude>my/package/model/**/*.class</exclude>
<exclude>my/package/exception/**/*.class</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>