Maven 2.x Cobertura Plugin

Interoperability problem with AspectJ plugin

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 2.2
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    cobertura-maven-plugin 2.2-SNAPSHOT
    aspectj-maven-plugin 1.0-beta-4-SNAPSHOT
  • Number of attachments :
    1

Description

Is someone can help me to fix this problem ?

Regards.

This is the stacktrace :

2007-12-18 17:35:45,010 [Thread-31033] INFO - [INFO] Preparing surefire-report:report-only
2007-12-18 17:35:45,024 [Thread-31033] INFO - [INFO] No goals needed for project - skipping
2007-12-18 17:35:45,024 [Thread-31033] INFO - [INFO] Preparing cobertura:cobertura
2007-12-18 17:35:45,041 [Thread-31033] INFO - [INFO] [aspectj:compile {execution: default}]
2007-12-18 17:35:45,186 [Thread-31033] INFO - [INFO] [resources:resources]
2007-12-18 17:35:45,186 [Thread-31033] INFO - [INFO] Using default encoding to copy filtered resources.
2007-12-18 17:35:45,193 [Thread-31033] INFO - [INFO] [compiler:compile]
2007-12-18 17:35:45,201 [Thread-31033] INFO - [INFO] Nothing to compile - all classes are up to date
2007-12-18 17:35:45,202 [Thread-31033] INFO - [INFO] [cobertura:instrument]
2007-12-18 17:35:46,725 [Thread-31033] INFO - [INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
2007-12-18 17:35:46,725 [Thread-31033] INFO - Instrumenting 22 files to /SOFT/INT/quickbuild-1.2.12/working/root/decalog-framework/HEAD/checkouts/decalog-framework/common-application/target/generated-classes/cobertura
2007-12-18 17:35:46,725 [Thread-31033] INFO - Cobertura: Saved information on 22 classes.
2007-12-18 17:35:46,725 [Thread-31033] INFO - Instrument time: 822ms
2007-12-18 17:35:46,725 [Thread-31033] INFO -
2007-12-18 17:35:46,725 [Thread-31033] INFO - [INFO] Instrumentation was successful.
2007-12-18 17:35:46,729 [Thread-31033] INFO - [INFO] [aspectj:test-compile {execution: default}]
2007-12-18 17:35:47,310 [Thread-31033] INFO - [ERROR] Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
2007-12-18 17:35:47,310 [Thread-31033] INFO - [ERROR] Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
2007-12-18 17:35:47,310 [Thread-31033] INFO - [ERROR] Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
2007-12-18 17:35:47,356 [Thread-31033] INFO - [ERROR] Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
2007-12-18 17:35:47,356 [Thread-31033] INFO - [ERROR] Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
2007-12-18 17:35:47,356 [Thread-31033] INFO - [ERROR] Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
2007-12-18 17:35:47,375 [Thread-31033] INFO - [INFO] ------------------------------------------------------------------------
2007-12-18 17:35:47,375 [Thread-31033] INFO - [ERROR] BUILD ERROR
2007-12-18 17:35:47,375 [Thread-31033] INFO - [INFO] ------------------------------------------------------------------------
2007-12-18 17:35:47,382 [Thread-31033] INFO - [INFO] Compiler errors :
2007-12-18 17:35:47,382 [Thread-31033] INFO - error at <Unknown>::0 Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
2007-12-18 17:35:47,382 [Thread-31033] INFO - error at <Unknown>::0 Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
2007-12-18 17:35:47,382 [Thread-31033] INFO - error at <Unknown>::0 Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
2007-12-18 17:35:47,383 [Thread-31033] INFO - error at com/sungard/decalog/framework/application/observing/Observing.java::0 Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
2007-12-18 17:35:47,383 [Thread-31033] INFO - error at com/sungard/decalog/framework/application/observing/Observing.java::0 Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)
2007-12-18 17:35:47,383 [Thread-31033] INFO - error at com/sungard/decalog/framework/application/observing/Observing.java::0 Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g' or '<javac debug='true'.../>' in Ant)

Activity

Hide
Ivan POPOV added a comment -

This problem only appears with the 2.2 version of the plugin.

Show
Ivan POPOV added a comment - This problem only appears with the 2.2 version of the plugin.
Hide
Dennis Lundberg added a comment -

Is this related to MCOBERTURA-41?

Show
Dennis Lundberg added a comment - Is this related to MCOBERTURA-41?
Hide
Ivan popov added a comment - - edited

Given the stacktrace, I don't think so.
In my case, it seems as if cobertura use code that was not compiled by aspectj first.

Show
Ivan popov added a comment - - edited Given the stacktrace, I don't think so. In my case, it seems as if cobertura use code that was not compiled by aspectj first.
Hide
Joris De Veirman added a comment -

The same issue occurs with 'aspectj-maven-plugin 1.0'

Show
Joris De Veirman added a comment - The same issue occurs with 'aspectj-maven-plugin 1.0'
Hide
bhaskar karambelkar added a comment -

This issue occurs when you have aspects in your main source , that don't advice any class in your test source.
Simply split the execution of the aspectj plugin in 2 executions, one for the compile goal to compile your main sources, and another for the test-compile goal for compiling the test sources.
And in the configuration for the test-compile execution add the following line.

<weaveWithAspectsInMainSourceFolder>false</weaveWithAspectsInMainSourceFolder>

This will tell agc, to not weave aspects in main source into test classes.

Below is the full configuration of the aspectj plugin.

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<verbose>true</verbose>
<complianceLevel>1.5</complianceLevel>
<source>1.5</source>
<showWeaveInfo>true</showWeaveInfo>
<outxml>true</outxml>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
<includes>
<include>*/.java</include>
</includes>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<verbose>true</verbose>
<complianceLevel>1.5</complianceLevel>
<source>1.5</source>
<showWeaveInfo>true</showWeaveInfo>
<outxml>true</outxml>
<weaveWithAspectsInMainSourceFolder>false</weaveWithAspectsInMainSourceFolder>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
<includes>
<include>*/.java</include>
</includes>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>

Show
bhaskar karambelkar added a comment - This issue occurs when you have aspects in your main source , that don't advice any class in your test source. Simply split the execution of the aspectj plugin in 2 executions, one for the compile goal to compile your main sources, and another for the test-compile goal for compiling the test sources. And in the configuration for the test-compile execution add the following line. <weaveWithAspectsInMainSourceFolder>false</weaveWithAspectsInMainSourceFolder> This will tell agc, to not weave aspects in main source into test classes. Below is the full configuration of the aspectj plugin. <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>aspectj-maven-plugin</artifactId> <executions> <execution> <id>compile</id> <goals> <goal>compile</goal> </goals> <configuration> <verbose>true</verbose> <complianceLevel>1.5</complianceLevel> <source>1.5</source> <showWeaveInfo>true</showWeaveInfo> <outxml>true</outxml> <aspectLibraries> <aspectLibrary> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> </aspectLibrary> </aspectLibraries> <includes> <include>*/.java</include> </includes> </configuration> </execution> <execution> <id>test-compile</id> <goals> <goal>test-compile</goal> </goals> <configuration> <verbose>true</verbose> <complianceLevel>1.5</complianceLevel> <source>1.5</source> <showWeaveInfo>true</showWeaveInfo> <outxml>true</outxml> <weaveWithAspectsInMainSourceFolder>false</weaveWithAspectsInMainSourceFolder> <aspectLibraries> <aspectLibrary> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> </aspectLibrary> </aspectLibraries> <includes> <include>*/.java</include> </includes> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>${aspectj.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjtools</artifactId> <version>${aspectj.version}</version> </dependency> </dependencies> </plugin>
Hide
Ron added a comment -

Also effects cobertura-maven-plugin 2.3-SNAPSHOT with aspectj-maven-plugin 1.1 .
cobertura-maven-plugin 2.1 with aspectj-maven-plugin 1.1 works fine.

@bhaskar karambelkar: Your suggested fix doesn't work for me. My setup is an abstract aspect in the main sources and a test implementation of that aspect in the test sources.

Show
Ron added a comment - Also effects cobertura-maven-plugin 2.3-SNAPSHOT with aspectj-maven-plugin 1.1 . cobertura-maven-plugin 2.1 with aspectj-maven-plugin 1.1 works fine. @bhaskar karambelkar: Your suggested fix doesn't work for me. My setup is an abstract aspect in the main sources and a test implementation of that aspect in the test sources.
Hide
Maxim Porges added a comment -

We still had issues with Cobertura 2.2 and AspectJ. However, we put all of our aspect code in to its own library, and we found that when we built our suite, we only had Cobertura errors for the aspects project itself. So, we used the excludes directive in the instrumentation configuration to exclude this library alone. We obviously don't get Cobertura reports for this library any more, but at least we get it for the rest of our suite.

Sample config below.

	<plugin>
	   <groupId>org.codehaus.mojo</groupId>
	   <artifactId>cobertura-maven-plugin</artifactId>
	   <version>2.2</version>
	   <configuration>
	      <instrumentation>
	         <excludes>
	            <exclude>com/foo/aspects/**/*.class</exclude>
	         </excludes>
	      </instrumentation>
	   </configuration>
	</plugin>
Show
Maxim Porges added a comment - We still had issues with Cobertura 2.2 and AspectJ. However, we put all of our aspect code in to its own library, and we found that when we built our suite, we only had Cobertura errors for the aspects project itself. So, we used the excludes directive in the instrumentation configuration to exclude this library alone. We obviously don't get Cobertura reports for this library any more, but at least we get it for the rest of our suite. Sample config below.
	<plugin>
	   <groupId>org.codehaus.mojo</groupId>
	   <artifactId>cobertura-maven-plugin</artifactId>
	   <version>2.2</version>
	   <configuration>
	      <instrumentation>
	         <excludes>
	            <exclude>com/foo/aspects/**/*.class</exclude>
	         </excludes>
	      </instrumentation>
	   </configuration>
	</plugin>
Hide
Robert Scholte added a comment -

So, another blocker which is already open for ages. With so many watchers and voters there should be at least one person who can provide a valid integration-test, right? Would be great if somebody could provide a mini-project which reproduces this case, just to be sure we're working on the right issue.

Show
Robert Scholte added a comment - So, another blocker which is already open for ages. With so many watchers and voters there should be at least one person who can provide a valid integration-test, right? Would be great if somebody could provide a mini-project which reproduces this case, just to be sure we're working on the right issue.
Hide
Robert Scholte added a comment -

Lowered priority to critical, since it's not a blocker for the plugin itself, but for a typical case.

Show
Robert Scholte added a comment - Lowered priority to critical, since it's not a blocker for the plugin itself, but for a typical case.
Hide
nicolas de loof added a comment -

I tried to reproduce this issue with a large scope aspect that applies both to sources and tests. I attach the test project.

using aspectj-maven-plugin 1.2 I get the reported error
"[ERROR] Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g'"

Seems the AJC compiler expect to get debug information in bytecode, and the cobertura instrumented classes don't include them.

using LATEST plugins for aspectJ (1.3) I get the expected coverage report without any error.
This plugin upgrades AspectJ to 1.6.5, that may fix this issue.

If anyone still has this issue, please add some classes / configuration / test cases to the demo project so that we can investigate further.

Show
nicolas de loof added a comment - I tried to reproduce this issue with a large scope aspect that applies both to sources and tests. I attach the test project. using aspectj-maven-plugin 1.2 I get the reported error "[ERROR] Cannot read debug info for @Aspect to handle formal binding in pointcuts (please compile with 'javac -g'" Seems the AJC compiler expect to get debug information in bytecode, and the cobertura instrumented classes don't include them. using LATEST plugins for aspectJ (1.3) I get the expected coverage report without any error. This plugin upgrades AspectJ to 1.6.5, that may fix this issue. If anyone still has this issue, please add some classes / configuration / test cases to the demo project so that we can investigate further.
Hide
nicolas de loof added a comment -

can be fixed by upgrading to aspectj-maven-plugin 1.3+

Show
nicolas de loof added a comment - can be fixed by upgrading to aspectj-maven-plugin 1.3+
Hide
nicolas de loof added a comment -

This issue is related (AFAIK) to https://bugs.eclipse.org/bugs/show_bug.cgi?id=279298 that is fixed in AspectJ 1.6.4+

Show
nicolas de loof added a comment - This issue is related (AFAIK) to https://bugs.eclipse.org/bugs/show_bug.cgi?id=279298 that is fixed in AspectJ 1.6.4+

People

Vote (6)
Watch (8)

Dates

  • Created:
    Updated:
    Resolved: