Maven 1.x Clover Plugin

Clover report is not generated when using Maven AspectJ plugin

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Blocker Blocker
  • Resolution: Unresolved
  • Affects Version/s: 1.10
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Maven 1.0.2 on Windows XP
  • Number of attachments :
    2

Description

When I am using AspectJ plugin with this lines in my maven.xml file:
<preGoal name="java:compile">
<attainGoal name="aspectj"/>
</preGoal>

the Clover report is not generated. The following message is presented:

clover:report:
[echo] No Clover database found, skipping report generation

The folder "target\clover\database" stays empty.
--------------------------------------------------------------------------------------------------
When I am using AspectJ plugin with this lines in my maven.xml file:
<preGoal name="java:compile">
<attainGoal name="aspectj:compile"/>
</preGoal>

an empty Clover report is generated, although there is one test in the project. The following message is presented:

[clover-report] No coverage data found for 'C:\eclipse\workspace\Introduction Example\target\clover\database\clover_coverage.db'.

The file "clover_coverage.db" is created at folder "target\clover\database"

--------------------------------------------------------------------------------------------------
When I am using AspectJ plugin with no preGoal for "java:compile" the Clover report is generated properly.

--------------------------------------------------------------------------------------------------

The MPCLOVER-27 issue reports this same problem, but did not provide data to reproduce it.

Thank you.

Activity

Hide
Wim Deblauwe added a comment -

I have attached a different testcase. It should compile without problems and it follows closely the best principles of Maven and the documentations of both AspectJ and Clover plugins. When I run "maven site", no clover report is generated. The test are being run twice and the compilation also happens twice.

Show
Wim Deblauwe added a comment - I have attached a different testcase. It should compile without problems and it follows closely the best principles of Maven and the documentations of both AspectJ and Clover plugins. When I run "maven site", no clover report is generated. The test are being run twice and the compilation also happens twice.
Hide
Lukas Theussl added a comment -

Thanks Wim!

It seems that I misunderstood this issue, at least the title is strongly misleading: the clover report is generated, only the aspectj source files are not included in the coverage report.

Now as far as I understand it, this is not a Maven issue. Clover uses source code instrumentation for it's coverage analysis (http://cenqua.com/clover/doc/faq.html#instrumentation), that means that only .java files can actually be instrumented by clover.
AspectJ compiles directly from .aj to .class with no intermediate .java stage. I've found this thread on the aspectj Mailing list instructive: http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg02377.html

If you agree, I think this issue can be closed as 'won't fix', unless you have a way to make clover work with aspectJ that we could implement in Maven.

Show
Lukas Theussl added a comment - Thanks Wim! It seems that I misunderstood this issue, at least the title is strongly misleading: the clover report is generated, only the aspectj source files are not included in the coverage report. Now as far as I understand it, this is not a Maven issue. Clover uses source code instrumentation for it's coverage analysis (http://cenqua.com/clover/doc/faq.html#instrumentation), that means that only .java files can actually be instrumented by clover. AspectJ compiles directly from .aj to .class with no intermediate .java stage. I've found this thread on the aspectj Mailing list instructive: http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg02377.html If you agree, I think this issue can be closed as 'won't fix', unless you have a way to make clover work with aspectJ that we could implement in Maven.
Hide
Lukas Theussl added a comment -

FYI: The current 1.2-SNAPSHOT version of the m1 cobertura plugin has been updated to cobertura 1.7 which includes support for aspectj compiled classes. I checked that it works for your test project (with <preGoal name="cobertura:report"><attainGoal name="aspectj:compile"/></preGoal>), you need to install the snapshot from cvs though.

Show
Lukas Theussl added a comment - FYI: The current 1.2-SNAPSHOT version of the m1 cobertura plugin has been updated to cobertura 1.7 which includes support for aspectj compiled classes. I checked that it works for your test project (with <preGoal name="cobertura:report"><attainGoal name="aspectj:compile"/></preGoal>), you need to install the snapshot from cvs though.
Hide
Wim Deblauwe added a comment -

I'm afraid you misunderstood, because when I run maven site, the clover report is not generated. I don't care currently if the aspectj sources are not included in the coverage, I just want to get the clover report on my normal java files.

Show
Wim Deblauwe added a comment - I'm afraid you misunderstood, because when I run maven site, the clover report is not generated. I don't care currently if the aspectj sources are not included in the coverage, I just want to get the clover report on my normal java files.
Hide
Lukas Theussl added a comment -

Ok, I think I got it now.
If you don't need the aspects during site generation then you can just comment out the preGoal, you should get the clover report as normal then,
I just need to figure out why this preGoal definition disturbs the clover plugin...

Show
Lukas Theussl added a comment - Ok, I think I got it now. If you don't need the aspects during site generation then you can just comment out the preGoal, you should get the clover report as normal then, I just need to figure out why this preGoal definition disturbs the clover plugin...
Hide
Lukas Theussl added a comment -

Wim,

I think I finally figured this one out: the reason why clover doesn't work after aspectj is that ant's iajc task is configured by default to compile aspect .aj and java sources. When the javac task runs afterwards, it sees an up-to-date .class file of the java source file and skips another compilation. But clover is configured to run only on javac-generated sources.

So I think the solution is simply to tell aspectj to only compile .aj source files: setting maven.aspectj.src.argfilesOnly=true for your test project gives me the clover report. However, I don't know if this is a workable solution for you, also the argfilesOnly property does not seem to be documented on the properties page of the aspectj plugin, I will add that shortly.

Show
Lukas Theussl added a comment - Wim, I think I finally figured this one out: the reason why clover doesn't work after aspectj is that ant's iajc task is configured by default to compile aspect .aj and java sources. When the javac task runs afterwards, it sees an up-to-date .class file of the java source file and skips another compilation. But clover is configured to run only on javac-generated sources. So I think the solution is simply to tell aspectj to only compile .aj source files: setting maven.aspectj.src.argfilesOnly=true for your test project gives me the clover report. However, I don't know if this is a workable solution for you, also the argfilesOnly property does not seem to be documented on the properties page of the aspectj plugin, I will add that shortly.
Hide
Lukas Theussl added a comment -

Small correction: the maven.aspectj.src.argfilesOnly option was only introduced in aspectj-plugin-4.0, which I just released a few minutes ago.

Show
Lukas Theussl added a comment - Small correction: the maven.aspectj.src.argfilesOnly option was only introduced in aspectj-plugin-4.0, which I just released a few minutes ago.
Hide
Wim Deblauwe added a comment -

ok, thanks for the info, I will try the new version.

Does that mean that the java files that are part of the same project will not be adviced with the aspects if only the .aj files are compiled with the aspectj compiler? For that is no problem, but if that is the case, you should document it properly I guess.

Show
Wim Deblauwe added a comment - ok, thanks for the info, I will try the new version. Does that mean that the java files that are part of the same project will not be adviced with the aspects if only the .aj files are compiled with the aspectj compiler? For that is no problem, but if that is the case, you should document it properly I guess.
Hide
Wim Deblauwe added a comment -

I'm afraid it does not work for me, since my aspects have a dependency on my java files, so I would need to compile them as a whole

Show
Wim Deblauwe added a comment - I'm afraid it does not work for me, since my aspects have a dependency on my java files, so I would need to compile them as a whole

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: