IMHO this is due to wrong moment when cobertura performs instrumentation (after compile not after test-compile). Look at following log from maven execution (mvn clean instal site:site):

[INFO] Preparing cobertura:cobertura
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /xxx/src/main/resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [aspectj:compile {execution: default}]
[INFO] No modifications found skipping aspectJ compile
[INFO] [cobertura:instrument {execution: default-instrument}]
[INFO] Cobertura 1.9.4.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Instrumenting 96 files to /xxx/target/generated-classes/cobertura
Cobertura: Saved information on 96 classes.
Instrument time: 370ms

[INFO] Instrumentation was successful.
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [aspectj:test-compile {execution: default}]
[ERROR] ABORT
2013-09-20 13:19:29 org.aspectj.weaver.tools.Jdk14Trace info
INFO: Dumping to /xxx/./ajcore.20130920.131929.938.txt
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Compiler errors:
abort ABORT -- (RuntimeException) Problem processing attributes in /xxx/target/generated-classes/cobertura/XXX.class
Problem processing attributes in /xxx/generated-classes/cobertura/XXX.class
java.lang.RuntimeException: Problem processing attributes in /xxx/target/generated-classes/cobertura/XXX.class

As you can see execution of aspectj:test-compile gets confused, because test classes are already instrumented.

IMHO there are two solutions - classes must be instrumented separately for main and for test AFTER compilation (may be hard to do) or instrumentation must be performed after test-compile.

Also note that there is workaround available through reconfiguration of aspectj compiler:

<plugins>
	<plugin>
		<groupId>org.codehaus.mojo</groupId>
		<artifactId>aspectj-maven-plugin</artifactId>
		<version>1.5</version>
		<configuration>
			<source>1.6</source>
			<target>1.6</target>
			<complianceLevel>1.6</complianceLevel>
		</configuration>
		<executions>
			<execution>
				<!-- this is workaround for cobertura. Phase is by default 'compile' 
					what causes some problems, because goes in conflict with instrumentation -->
				<phase>process-sources</phase>
				<goals>
					<goal>compile</goal>
					<goal>test-compile</goal>
				</goals>
			</execution>
		</executions>
	</plugin>
</plugins>

Also be aware that in previous versions - prior 1.3 - by default aspectj-maven-plugin was bound to process-sources phase by default. And since 1.3 it is bound to compile/test-compile phase. And now there is a discussion if this is fine:

https://jira.codehaus.org/browse/MASPECTJ-92

However IMHO both problems are related but separate and it still seems to me that cobertura plugin should perform instrumentation later, as it seems to be safer.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Reply via email to