Symptoms
When integrating clover into your build, the build fails with duplicate class errors:
[INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Compilation failure /Users/amyers/Applications/clover/mavenbook-examples-1-SNAPSHOT/ch05-simple-web/simple-webapp/target/clover/src-instrumented/com/atlassian/jira/soap/client/PingStringInput.java:[35,7] duplicate class: com.atlassian.jira.soap.client.PingStringInput /Users/amyers/Applications/clover/mavenbook-examples-1-SNAPSHOT/ch05-simple-web/simple-webapp/target/jaxws/wsimport/java/com/atlassian/jira/soap/client/PingServicePortType.java:[23,7] duplicate class: com.atlassian.jira.soap.client.PingServicePortType /Users/amyers/Applications/clover/mavenbook-examples-1-SNAPSHOT/ch05-simple-web/simple-webapp/target/clover/src-instrumented/com/atlassian/jira/soap/client/ObjectFactory.java:[22,7] duplicate class: com.atlassian.jira.soap.client.ObjectFactory /Users/amyers/Applications/clover/mavenbook-examples-1-SNAPSHOT/ch05-simple-web/simple-webapp/target/clover/src-instrumented/com/atlassian/jira/soap/client/PingService.java:[21,7] duplicate class: com.atlassian.jira.soap.client.PingService /Users/amyers/Applications/clover/mavenbook-examples-1-SNAPSHOT/ch05-simple-web/simple-webapp/target/jaxws/wsimport/java/com/atlassian/jira/soap/client/package-info.java:[1,0] package com.atlassian.jira.soap.client has already been annotated
Cause
The jaxws-maven-plugin
adds the output directory for the generated sources to the compile source roots. Clover changes the ${project.build.sourceDirectory
} to target/clover/src-instrumented
when it performs the instrumentation, thus maven ends up having both the original generated code and the instrumented code on the compile path.
Resolution
Configure the jaxws-maven-plugin
to use ${project.build.sourceDirectory
} as the <sourceDestDirectory>
.
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxws-maven-plugin</artifactId> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>wsimport</goal> </goals> </execution> </executions> <configuration> <packageName>com.atlassian.example.wsdl.client</packageName> <sourceDestDir>${project.build.sourceDirectory}</sourceDestDir> </configuration> </plugin>