英文:
Exclude test directories in multi-module maven projecty from JaCoCo when using Azure build pipeline
问题
这应该很容易,所以请帮助指导我正确的方向。
我已经成功地使用Maven在Azure Pipeline中构建我的Java项目。我也成功地获得了JaCoCo覆盖率报告。
我有一个包含多个模块的Maven项目。下面是一个示例项目结构。我想要排除所有子目录/包中的src/test/java中的内容。
我的项目
模块1
src/main/java/...
src/test/java/...
pom.xml
模块2
src/main/java/...
src/test/java/...
pom.xml
pom.xml
我本来期望可以设置codeCoverageClassFilter
为-:*.src.test.java*.*
,但我的各种尝试都没有奏效。如何正确排除所有这些测试目录的语句是什么?
英文:
This feels like it should be easy, so please help point me in the correct direction.
I am successfully using maven to build my java project using a Azure Pipeline. I am also successfully getting JaCoCo coverage reports.
I have a maven project with multiple modules. Below is a sample project structure. I want to exclude everything in all the sub src/test/java directories/packages.
myproject
mod1
src/main/java/...
src/test/java/...
pom.xml
mod2
src/main/java/...
src/test/java/...
pom.xml
pom.xml
I would have expected something like setting codeCoverageClassFilter
to -:*.src.test.java*.*
, but none of my variations have worked. What is the correct statement to exclude all these test directories?
答案1
得分: 1
为了排除测试,请在pom父级中添加以下配置:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<configuration>
<excludes>
<exclude>com/acme/test/*</exclude>
</excludes>
</configuration>
<executions>
<!-- 为集成测试准备代理 -->
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
英文:
For excluded test add next configuration in pom parent
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<configuration>
<excludes>
<exclude>com/acme/test/*</exclude>
</excludes>
</configuration>
<executions>
<!-- prepare agent for measuring integration tests -->
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论