gpt4 book ai didi

java - Maven clover2触发重复类异常

转载 作者:行者123 更新时间:2023-11-30 03:30:49 25 4
gpt4 key购买 nike

这是引用 https://jira.atlassian.com/browse/CLOV-1471 上的 JIRA 票证

该问题与 JIRA 仪表板上发布的问题类似,即:我们有几个 Maven 项目,它们有多个源目录。非默认目录是使用 build-helper 插件添加的。 clover2:setup 目标检测所有源文件夹,但随后将所有非生成的目录设置为 Maven 项目上的源文件夹。这会导致编译错误,因为源文件同时存在于 clover 检测源和原始位置中。

这是我们如何使用 build-helper-maven-plugin

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-shared-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>../SomeOtherModule1/src/main/java/com</source>
<source>../SomeOtherModule2/src/main/java/com</source>
<source>../SomeOtherModule3/src/main/java/com</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>

这就是我们在构建配置文件中使用 clover2 插件的方式:

<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<version>4.0.0</version>
<configuration combine.self="override">
<targetPercentage>$
{code_coverage_target}
</targetPercentage>
<licenseLocation>$
{clover_license_location}
</licenseLocation>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>instrument-test</goal>
<goal>check</goal>
<goal>clover</goal>
</goals>
</execution>
</executions>
</plugin>

没有 clover 插件,构建可以正常编译。但是添加 clover 插件后,我们收到几个错误,指出发现了重复的类。

我在这里遗漏了什么吗?

最佳答案

我认为这是由于您使用 clover2:instrument 而不是 clover2:setup 目标造成的。 clover2:instrument fork 了一个自定义构建生命周期,并在此构建周期中它在“验证”阶段执行检测。由于您的“添加源”目标绑定(bind)到生成源阶段,因此 build-helper-maven-plugin 在 Clover 之后而不是之前运行。

我建议在验证或初始化阶段使用 clover2:setup(即在生成源阶段之前)。

关于java - Maven clover2触发重复类异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29105389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com