Duplicate class errors with Clover and jaxws-maven plugin

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

症状

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

原因

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.

ソリューション

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>
最終更新日 2013 年 5 月 17 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.