我们有一个使用clover和axistools-wsdl2java插件的maven项目 . Platfrom是窗户 .
我们使用clover 2.4.0插件来获取集成在项目的pom.xml中的代码覆盖率 . 配置了clover插件,如下所示 .
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<version>2.4.0</version>
<configuration> <generatePdf>true</generatePdf>
<generateXml>true</generateXml>
<generateHtml>true</generateHtml>
<licenseLocation>C:/EcasSVNCO/ews/ews-mvn/ewsbase/src/test/resources/license/clover.license</licenseLocation>
<reportDescriptor>C:/EcasSVNCO/ews/ews-mvn/ewsbase/src/test/resources/descriptor/default-clover-report.xml</reportDescriptor>
<excludes>
<exclude>${basedir}/src/main/java/*.java</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>instrument</goal>
<goal>clover</goal>
</goals>
</execution>
<!--
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>instrument</goal>
<goal>clover</goal>
</goals>
</execution>
<execution>
<id>site</id>
<phase>pre-site</phase>
<goals>
<goal>instrument</goal>
<goal>clover</goal>
</goals>
</execution>
-->
</executions>
</plugin>
此外,还有axistools插件用于使用wsdl文件生成类,其配置如下 .
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<sourceDirectory>${base.dir}/src/main/resources/wsdl</sourceDirectory>
<outputDirectory>${base.dir}/src/main/java</outputDirectory>
<wsdlFiles>
<wsdlFiles>wsecas.wsdl</wsdlFiles>
</wsdlFiles>
<packageSpace>com.symantec.wsecas</packageSpace>
<testCases>true</testCases>
<serverSide>true</serverSide>
<phase>install</phase>
<subPackageByFileName>true</subPackageByFileName>
</configuration>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
当我们执行命令'mvn clean install'时,编译就可以了 . 然后运行第一个axistool的wsdl2java目标,并在各自的目录中生成源文件 . 下一个clover插件尝试通过运行单元测试用例来检测源代码,此插件将已检测的源代码放在 / target / clover / src / main / java / ...之后然后触发“编译”目标进行编译所有的源代码 . 在编译源代码时,会添加两个源路径,即 / src / main / java / ...和 / target / clover / src / main / java / ...,两者都有相同的类 . 当maven编译器尝试编译这些源时,编译失败,抛出“Duplicate Class Error” .
但是当我们评论出axistools插件时,三叶草仪器和报告生成就可以了 .
如果您有任何人遇到类似问题'重复课程错误',请就此向我们提供指导 . 任何建议和帮助将不胜感激 .
1 回答
似乎问题是你的Axis插件生成了src / main / java的源代码(它应该是target / src生成的) .
当调用Clover时,它将首先从src / main / java中获取“普通”源,检测它们并放入target / clover / java . Next Clover将更改目标/ clover / java替换src / main / java的源根列表 .
接下来,AXIS代码生成发挥作用,它再次生成新的源到src / main / java,并将此目录添加为额外的源根目录 .
因此,编译器在两个位置看到相同的源集(即非生成的源)并抱怨它 .
这种情况与Clover知识库中描述的情况非常相似:
https://confluence.atlassian.com/display/CLOVERKB/Duplicate+class+errors+with+Clover+and+JAXB+or+JAXB2+plugin
https://confluence.atlassian.com/display/CLOVERKB/Duplicate+class+errors+with+Clover+and+jaxws-maven+plugin
您将在这些文章中找到可能的解决方案 .