[ 
http://jira.codehaus.org/browse/MCOBERTURA-70?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=206576#action_206576
 ] 

Martin Zeltner commented on MCOBERTURA-70:
------------------------------------------

Hello

Also with version 2.2 and forkMode the problem was still there.
I have now patched cobertura itself and the maven plugin, so that it works fine.

The problem was, that for saving the cobertura.ser file, just a shutdown hook 
was installed. The solution is to trigger cobertura to save the file 
additionally before the JVM ends. For that I added a new timer task in class 
ProjectData (see appended class =ConditionalSaveTimer=). Every half second the 
ConditionalSaveTimer checks if there is a directory "pleaseSaveCobertura" in 
the directory where the cobertura.ser is saved. If yes, cobertura saves. That 
is all we do in cobertura.

In the maven plugin we must now create such a "trigger directory" to trigger 
cobertura to save. We execute the following line in method "executeReport":
"CoberturaDataUtil.waitUntilDefaultCoberturaCoverageFileSecurelySaved(getLog());"
See attached files "CoberturaReportMojo" and "CoberturaDataUtil"

All jars are relased on EL4J's Maven 2 repo. Just use them! 
http://public-el4.elca-services.ch/el4j/maven2repository/

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>2.3-el4j_20100108_1400</version>
</plugin>

Do not forget the configure the plugin twice, in build AND reporting section of 
your pom!

Because there are two report goals that does execute cobertura, do not forget 
to configure the reportSets:
<reportSets>
    <reportSet>
        <id>standardReports</id>
        <reports>
            <report>cobertura</report>
        </reports>
    </reportSet>
</reportSets>

To complete the listing, here the cobertura dependency for your dependency 
management:
<dependency>
    <groupId>net.sourceforge.cobertura</groupId>
    <artifactId>cobertura</artifactId>
    <version>1.9-el4j_20100108_1600</version>
</dependency>

BTW: To record the code coverage while working with the web or gui application, 
we have created another plugin. See 
http://el4j.sourceforge.net/plugins/maven-cobertura-runtime-plugin/index.html


Cheers,
Martin Zeltner
http://el4j.sourceforge.net

> I must run 'mvn cobertura:cobertura' twice to get a valid coverage report.
> --------------------------------------------------------------------------
>
>                 Key: MCOBERTURA-70
>                 URL: http://jira.codehaus.org/browse/MCOBERTURA-70
>             Project: Maven 2.x Cobertura Plugin
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Gary Kind
>         Attachments: CoberturaDataUtil.java, CoberturaReportMojo.java, 
> ConditionalSaveTimer.java, ProjectData.java
>
>
> Our nightly build does:
> 'mvn clean'
> 'mvn install'
> 'mvn cobertura'
> 'mvn site'
> We have found that for the last couple of months (or possibly more), our 
> coverage reports are showing 0% coverage on all tests. I have found that we 
> have to run 'mvn cobertura:cobertura' TWICE! to get a valid coverage report.  
> What gives?  Is there any workaround?  I have tried all sorts of things but 
> nothing really works.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
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