Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Ability to generate reports as part of regular build (not site) #39

Open
msiemczyk opened this issue Jul 20, 2018 · 1 comment

Comments

@msiemczyk
Copy link

msiemczyk commented Jul 20, 2018

I've have been using Cobertura via maven site goal for very long time and maven-site-plugin is nothing but trouble. Our project are large with many different dependencies, with many jar including different version of libraries like Guava, etc.

The maven-site-plugin seems to load plugins and dependencies into class path differently, which causes all kinds of random build failures while doing static code analysis. The normal build (mvn clean install) will pass, but mvn site will fail.

For this reason I really wanted to be able to wire cobertura into normal build life cycle. Turns out that we can already wire the instrument goal, but not the report generation (cobertura.ser --> cobertura.xml) that can be consumed by the Jenkins plugin. Adding new generate-report goal allowed me to wire Cobertura directly into build (mvn clean install).

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>${coberturaPlugin.version}</version>
    <executions>
        <execution>
            <id>cobertura-clean</id>
            <goals>
                <goal>clean</goal>
            </goals>
        </execution>
        <execution>
            <id>cobertura-instrument-code</id>
            <phase>process-classes</phase>
            <goals>
                <goal>instrument</goal>
            </goals>
        </execution>
        <execution>
            <id>cobertura-generate-report</id>
            <phase>verify</phase>
            <goals>
                <goal>generate-report</goal>
            </goals>
        </execution>
    </executions>
</plugin>

I added this new generate-report a while back and it has been working rather good. There was some projects with our custom OSGI plugins that I had to exclude because I couldn't figure out what is the problem. Also because Cobertura actually modified the target class path in the maven environment I had to also add this 'hack' to maven-bundle-plugin.

image

@msiemczyk
Copy link
Author

msiemczyk@23a6fca

Added generate-report goal that can be used as part of normal build.

Using maven-site-plugin to generate cobertura was causing all kinds of
weird dependency issues so we need alternative means of generating the
cobertura.xml report. The report is generated based on previously
generated cobertura.ser file that is created by calling
cobertura:instrument first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant