jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven 2.x Cobertura Plugin
  • MCOBERTURA-41

Corbetura doesn't play well with AspectJ

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Labels:
    None

Description

I'm using AspectJ on my project (Tapestry 5) and want to generate a cobeturer (what an awkward name!) report.

The report generates warnings; further the final output shows 0% coverage on all code.

[INFO] Generate "Cobertura Test Coverage" report.
[INFO] Cobertura 1.7 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Cobertura: Loaded information on 164 classes.
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - Cannot find source file during CCN c
omputation, source=[org/apache/tapestry/internal/aspects/AbstractClassTargetting.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - Cannot find source file during CCN c
omputation, source=[org/apache/tapestry/internal/aspects/CatchNullParameters.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - Cannot find source file during CCN c
omputation, source=[org/apache/tapestry/internal/aspects/InternalCatchNullParameters.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - Cannot find source file during CCN c
omputation, source=[org/apache/tapestry/internal/aspects/InternalOneShotChecks.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - Cannot find source file during CCN c
omputation, source=[org/apache/tapestry/internal/aspects/InternalSynchronization.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - Cannot find source file during CCN c
omputation, source=[org/apache/tapestry/internal/aspects/InternalUtilityChecks.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - Cannot find source file during CCN c
omputation, source=[org/apache/tapestry/internal/aspects/OneShotChecks.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - Cannot find source file during CCN c
omputation, source=[org/apache/tapestry/internal/aspects/Synchronization.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - Cannot find source file during CCN c
omputation, source=[org/apache/tapestry/internal/aspects/UtilityChecks.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.html.HTMLReport - Could not generate HTML file for source f
ile org/apache/tapestry/internal/aspects/InternalCatchNullParameters.java: Cannot find source file, name=[org/apache/tap
estry/internal/aspects/InternalCatchNullParameters.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.html.HTMLReport - Could not generate HTML file for source f
ile org/apache/tapestry/internal/aspects/InternalSynchronization.java: Cannot find source file, name=[org/apache/tapestr
y/internal/aspects/InternalSynchronization.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.html.HTMLReport - Could not generate HTML file for source f
ile org/apache/tapestry/internal/aspects/AbstractClassTargetting.java: Cannot find source file, name=[org/apache/tapestr
y/internal/aspects/AbstractClassTargetting.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.html.HTMLReport - Could not generate HTML file for source f
ile org/apache/tapestry/internal/aspects/InternalUtilityChecks.java: Cannot find source file, name=[org/apache/tapestry/
internal/aspects/InternalUtilityChecks.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.html.HTMLReport - Could not generate HTML file for source f
ile org/apache/tapestry/internal/aspects/UtilityChecks.java: Cannot find source file, name=[org/apache/tapestry/internal
/aspects/UtilityChecks.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.html.HTMLReport - Could not generate HTML file for source f
ile org/apache/tapestry/internal/aspects/CatchNullParameters.java: Cannot find source file, name=[org/apache/tapestry/in
ternal/aspects/CatchNullParameters.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.html.HTMLReport - Could not generate HTML file for source f
ile org/apache/tapestry/internal/aspects/InternalOneShotChecks.java: Cannot find source file, name=[org/apache/tapestry/
internal/aspects/InternalOneShotChecks.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.html.HTMLReport - Could not generate HTML file for source f
ile org/apache/tapestry/internal/aspects/OneShotChecks.java: Cannot find source file, name=[org/apache/tapestry/internal
/aspects/OneShotChecks.java]
[cobertura] INFO [main] net.sourceforge.cobertura.reporting.html.HTMLReport - Could not generate HTML file for source f
ile org/apache/tapestry/internal/aspects/Synchronization.java: Cannot find source file, name=[org/apache/tapestry/intern
al/aspects/Synchronization.java]
Report time: 1640ms

[INFO] Cobertura Report generation was successful.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 39 seconds
[INFO] Finished at: Wed Jul 26 19:50:19 PDT 2006
[INFO] Final Memory: 38M/63M
[INFO] ------------------------------------------------------------------------
bash-3.1$
bash-3.1$ mvn help
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Invalid task 'help': you must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroup
Id:pluginArtifactId:pluginVersion:goal
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Jul 26 19:52:36 PDT 2006
[INFO] Final Memory: 1M/2M
[INFO] ------------------------------------------------------------------------
bash-3.1$ mvn help:help
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'help'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Required goal not found: help:help
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Jul 26 19:52:42 PDT 2006
[INFO] Final Memory: 2M/5M
[INFO] ------------------------------------------------------------------------
bash-3.1$

I've attached my project's pom.xml.

Sorry I missed the BOF tonight at OSCON!

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. XML File
    pom.xml
    26/Jul/06 10:12 PM
    7 kB
    Howard M. Lewis Ship

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Nick Veys added a comment - 18/Aug/06 2:20 PM

I believe this is a result of an issue w/the aspectj plugin. Cobertura instruments the compiled source, then aspectj runs to compile the test sources. The bug http://jira.codehaus.org/browse/MOJO-456 is about aspectj re-compiling test AND source during test-compile, which blows away the instrumented sources.

Show
Nick Veys added a comment - 18/Aug/06 2:20 PM I believe this is a result of an issue w/the aspectj plugin. Cobertura instruments the compiled source, then aspectj runs to compile the test sources. The bug http://jira.codehaus.org/browse/MOJO-456 is about aspectj re-compiling test AND source during test-compile, which blows away the instrumented sources.
Hide
Permalink
Nick Veys added a comment - 23/Aug/06 3:05 PM

aspectj-maven-plugin 1.0-beta-2-SNAPSHOT should fix this issue, it did for us.

Show
Nick Veys added a comment - 23/Aug/06 3:05 PM aspectj-maven-plugin 1.0-beta-2-SNAPSHOT should fix this issue, it did for us.
Hide
Permalink
Matt Raible added a comment - 24/Sep/07 12:54 PM

I'm using the aspectj-maven-plugin 1.0-beta-2 and it doesn't solve this issue for me. If I remove the aspectj-maven-plugin's configuration from my pom.xml, Cobertura reports the correct coverage. Here's my aspectj configuration:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.0-beta-2</version>
    <configuration>
        <source>1.5</source>
        <verbose>true</verbose>
        <complianceLevel>1.5</complianceLevel>
        <showWeaveInfo>true</showWeaveInfo>
        <aspectLibraries>
            <aspectLibrary>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
            </aspectLibrary>
        </aspectLibraries>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Show
Matt Raible added a comment - 24/Sep/07 12:54 PM I'm using the aspectj-maven-plugin 1.0-beta-2 and it doesn't solve this issue for me. If I remove the aspectj-maven-plugin's configuration from my pom.xml, Cobertura reports the correct coverage. Here's my aspectj configuration:
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.0-beta-2</version>
    <configuration>
        <source>1.5</source>
        <verbose>true</verbose>
        <complianceLevel>1.5</complianceLevel>
        <showWeaveInfo>true</showWeaveInfo>
        <aspectLibraries>
            <aspectLibrary>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
            </aspectLibrary>
        </aspectLibraries>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Hide
Permalink
Dax Abraham added a comment - 13/Feb/08 6:23 AM

Ditto have tried with :

AspectJ Pluging: 1.0-beta-4-SNAPSHOT

and

Cobertura Plugin: 2.2-SNAPSHOT

But still no luck.

Show
Dax Abraham added a comment - 13/Feb/08 6:23 AM Ditto have tried with : AspectJ Pluging: 1.0-beta-4-SNAPSHOT and Cobertura Plugin: 2.2-SNAPSHOT But still no luck.
Hide
Permalink
Frederic Tardif added a comment - 25/Jan/10 3:14 PM

I am using aspectj-maven-plugin 1.2 with cobertura-maven-plugin 2.3 and I still have an issue.

Since I inject aspects in my src/main/java based on my src/test/aspects for my unittest with weaveMainSourceFolder=true

<plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.2</version>
        <executions>          
          <execution>
            <id>test-compile</id>
            <goals>
              <goal>test-compile</goal>
            </goals>
            <configuration>
              <weaveMainSourceFolder>true</weaveMainSourceFolder>           
              <XnoInline>true</XnoInline>
              <Xreweavable>true</Xreweavable>              
            </configuration>
          </execution>
        </executions>
      </plugin>

The instrumentation sequence seems to be impossible:

1- Cobertura instruments src/main/java in target/generated-classes/cobertura
2- Cobertura runs test-compile which runs aspectj which consequently instrument in parallel my src/main/java in target/test-compile with the aspects defined in src/test/aspects (since I have set weaveMainSourceFolder=true)
3- Cobertura then runs surefire with a classpath including both target/test-compile and target/generated-classes/cobertura (which it believes to be the cobertura's instrumented compilation of my src/main/java).
4- Then, probably because of the classpath order, my tests are run with the instrumented version of target/test-compile (with my own aspects that I had defined in my src/test/aspects). The classes are then not the one intrumented my cobertura, causing to show a 0% coverage.

The trouble is obviously that classes are instrumented twice from src/main/java instead of being re-instrumented one over the other.

I tried a workaround by doing something like: mvn test-compile cobertura:cobertura by specifying to the cobertura plugin to take target/test-compile as a basedir, but I figured out that cobertura seems to re-run test-compile goal after its own intrumentation...

I am afraid it is a design issue of the cobertura plugin.

Any idea to fix this?

Show
Frederic Tardif added a comment - 25/Jan/10 3:14 PM I am using aspectj-maven-plugin 1.2 with cobertura-maven-plugin 2.3 and I still have an issue. Since I inject aspects in my src/main/java based on my src/test/aspects for my unittest with weaveMainSourceFolder=true
<plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.2</version>
        <executions>          
          <execution>
            <id>test-compile</id>
            <goals>
              <goal>test-compile</goal>
            </goals>
            <configuration>
              <weaveMainSourceFolder>true</weaveMainSourceFolder>           
              <XnoInline>true</XnoInline>
              <Xreweavable>true</Xreweavable>              
            </configuration>
          </execution>
        </executions>
      </plugin>
The instrumentation sequence seems to be impossible: 1- Cobertura instruments src/main/java in target/generated-classes/cobertura 2- Cobertura runs test-compile which runs aspectj which consequently instrument in parallel my src/main/java in target/test-compile with the aspects defined in src/test/aspects (since I have set weaveMainSourceFolder=true) 3- Cobertura then runs surefire with a classpath including both target/test-compile and target/generated-classes/cobertura (which it believes to be the cobertura's instrumented compilation of my src/main/java). 4- Then, probably because of the classpath order, my tests are run with the instrumented version of target/test-compile (with my own aspects that I had defined in my src/test/aspects). The classes are then not the one intrumented my cobertura, causing to show a 0% coverage. The trouble is obviously that classes are instrumented twice from src/main/java instead of being re-instrumented one over the other. I tried a workaround by doing something like: mvn test-compile cobertura:cobertura by specifying to the cobertura plugin to take target/test-compile as a basedir, but I figured out that cobertura seems to re-run test-compile goal after its own intrumentation... I am afraid it is a design issue of the cobertura plugin. Any idea to fix this?
Hide
Permalink
nicolas de loof added a comment - 22/Apr/10 9:34 AM

Did anyone test this with aspectj-maven-plugin 1.3 ? This one include aspectJ Upgrade to 1.6.5, as 1.6.4 includes an important bug fix for wortking fine with Cobertura (https://bugs.eclipse.org/bugs/show_bug.cgi?id=279298), this may fix this issue as well.

I myself have an AspectJ + Cobertura project that failed generating a non 0% report for a while, but works fine after plugin upgrade.

Show
nicolas de loof added a comment - 22/Apr/10 9:34 AM Did anyone test this with aspectj-maven-plugin 1.3 ? This one include aspectJ Upgrade to 1.6.5, as 1.6.4 includes an important bug fix for wortking fine with Cobertura (https://bugs.eclipse.org/bugs/show_bug.cgi?id=279298), this may fix this issue as well. I myself have an AspectJ + Cobertura project that failed generating a non 0% report for a while, but works fine after plugin upgrade.
Hide
Permalink
Benson Margulies added a comment - 23/Apr/11 12:28 PM

Given (a) Nicolas' report that things are better, and (b) the lack of a runnable test case (a pom in isolation is not enough) I plan to close this unless someone yells.

Show
Benson Margulies added a comment - 23/Apr/11 12:28 PM Given (a) Nicolas' report that things are better, and (b) the lack of a runnable test case (a pom in isolation is not enough) I plan to close this unless someone yells.
Hide
Permalink
Yegor Bugayenko added a comment - 01/May/11 12:24 PM

Works fine for me with org.codehaus.mojo:aspectj-maven-plugin:1.3.1 and org.codehaus.mojo:cobertura-maven-plugin:2.4. I'm using very simple almost default configuration of them both.

Show
Yegor Bugayenko added a comment - 01/May/11 12:24 PM Works fine for me with org.codehaus.mojo:aspectj-maven-plugin:1.3.1 and org.codehaus.mojo:cobertura-maven-plugin:2.4. I'm using very simple almost default configuration of them both.

People

  • Assignee:
    Unassigned
    Reporter:
    Howard M. Lewis Ship
Vote (9)
Watch (12)

Dates

  • Created:
    26/Jul/06 10:12 PM
    Updated:
    01/May/11 12:24 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.