2013-05-14 52 views
0

我們有一個使用三葉草和axistools-wsdl2java插件的maven項目。 Platfrom是窗戶。maven項目中包含axistools和clover插件時出現重複類錯誤

我們使用clover 2.4.0插件來獲得集成在項目的pom.xml中的代碼覆蓋率。 按如下所示配置三葉草插件。

<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> 

而且,存在用於生成使用WSDL文件,其作爲下面配置類axistools插件。

<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目標,並在相應的目錄中生成源文件。 下一個三葉草插件嘗試通過運行單元測試用例來測試源代碼,當此插件將檢測到的源代碼放置在 {basedir}/target/clover/src/main/java/... 然後它會觸發「編譯」編譯所有源代碼的目標。編譯源代碼時,兩個源路徑被添加,即 {basedir}/src/main/java/...和{basedir}/target/clover/src/main/java/...都具有相同的類。 當maven編譯器嘗試編譯這些源編譯失敗,拋出「重複類錯誤」。

但是當我們註釋掉axistools插件時,三葉草儀器和報告生成會很好。

如果您有任何人遇到類似的問題'重複類錯誤',請在這方面指導我們。 任何建議和幫助將不勝感激。

回答

0

看來問題在於你的Axis插件生成源文件到src/main/java(它應該是一個目標/ src生成的)。

當Clover被調用時,它將首先從src/main/java中獲取'正常'源,並將它們放入target/clover/java中。接下來Clover會通過target/clover/java替換src/main/java的源根目錄。

接下來,AXIS代碼生成發揮作用,它會再次生成新的源文件到src/main/java中,並將此目錄作爲額外的源文件根目錄添加。

因此,編譯器會在兩個位置看到同一組來源(即未生成的來源)並抱怨它。

這種情況非常類似三葉草的知識庫中描述的:

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

,你會發現這些文章可能的解決方案。

相關問題