Maven clover2触发重复的类异常

时间:2015-03-17 17:08:23

标签: java maven clover

这是参考https://jira.atlassian.com/browse/CLOV-1471

的JIRA门票

问题类似于JIRA仪表板上发布的问题,即: 我们有几个具有多个源目录的maven项目。使用build-helper插件添加非默认目录。 clover2:安装目标检测所有源文件夹,但随后将所有未生成的目录设置为maven项目上的源文件夹。这会导致编译错误,因为源文件都存在于三叶草检测源和原始位置中。

以下是我们如何使用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插件之后,我们得到了几个错误,说明找到了重复的类。

我在这里错过了什么吗?

1 个答案:

答案 0 :(得分:2)

我认为这是由于你使用clover2:instrument而不是clover2:setup目标这一事实造成的。 clover2:工具分叉自定义构建生命周期,并在此构建周期中执行“验证”工具中的工具。相。由于您的“添加源”这一事实。目标绑定到generate-sources阶段,build-helper-maven-plugin在Clover之后而不是之前运行。

我建议使用clover2:setup绑定到验证或初始化阶段(即在generate-sources之前)。

相关问题