GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add aggregate-report that reports cross module code coverage for the maven plugin by johnoliver · Pull Request #97 · jacoco/jacoco

Conversation

@johnoliver

@johnoliver johnoliver commented May 2, 2013

Copy link
Copy Markdown

We have had issues with gaining accurate cross module code coverage numbers with jacoco. For instance when code in module A is touched during tests from module B, in our case when they are both part of a multi-module build.

This pull request makes it possible to report coverage numbers on classes outside of the current module. By adding a list of sourceFolders and classFolders which is a list of source and class folders outside of the current module to be scanned for classes to report coverage on.

The aggregate-report then concatenates the jacoco.exec files from reactor projects so that a unified report can be created.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mapoulin, karianna, and khmarbaise reacted with thumbs up emoji
All reactions
  • 👍 3 reactions
johnoliver and others added 14 commits March 13, 2013 14:48
@johnoliver
Add ability to add source and class dirs to the current projects list
e5d9b20
@johnoliver
tidy adding source folders
83fde2b
@johnoliver
Add mojo for processing parent poms
2c25fa4
@johnoliver
Remove unnessacery annotations, add npe check
34d82c0
@johnoliver
Fix comment
a5c8820
@johnoliver
Make stuff private and use getters/setters
9a762b2
@karianna
Merge pull request jacoco#1 from johnoliver/master
90074be
Add ability to add source and class dirs to the current projects list
@johnoliver
Form exec file via concatenating reactor projects
8a753d9
@johnoliver
Remove old file
de311ea
@johnoliver
Reduce try catch complexity
70e832d
@karianna
Merge pull request jacoco#3 from johnoliver/master
6be497b
Form exec file via concatenating reactor projects
John Oliver
Merge branch 'master' of git://github.com/jacoco/jacoco
d1d7b73
@karianna
Merge pull request jacoco#4 from johnoliver/master
b3e93ef
Update to latest Jacoco head
John Oliver
Merge branch 'master' of git://github.com/jacoco/jacoco
2c7db53
@melloware

melloware commented May 15, 2013

Copy link
Copy Markdown

Is this patch going to be implemented in Jacoco release soon? A lot of us desperately need this aggregate report feature for multi-module builds. Much appreciated for this patch keep up the great work!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vydra

vydra commented May 20, 2013

Copy link
Copy Markdown

Report looks good, but the 'check' goal does not seem to count coverage from all modules. Is there an example of how to configure it? I am testing here: https://github.com/lhazlewood/mvn-multi-module-web-with-jacoco-it

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@johnoliver

johnoliver commented May 22, 2013

Copy link
Copy Markdown
Author

@vydra Thanks for the feedback. Yes it does look like there is an issue with the check goal. Since I was purely looking at reporting I didn't look at this. But there seems like no reason why the same approach can't be used for check too.

I had a quick go with you project and producing the aggregate jacoco.exec worked by invoking the aggregate-report goal. Then I ran check after disabling the code that causes check to explicitly refuse to run over pom type projects. It seemed like it worked however it returned success despite obviously failing the requirements, so something is not right.

I will take a look and will keep you/this pull request updated on any improvements.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vydra

vydra commented May 22, 2013

Copy link
Copy Markdown

Sounds great!

On Wed, May 22, 2013 at 1:10 PM, John Oliver [email protected]:

@vydra https://github.com/vydra Thanks for the feedback. Yes it does
look like there is an issue with the check goal. Since I was purely looking
at reporting I didn't look at this. But there seems like no reason why the
same approach can't be used for check too.

I had a quick go with you project and producing the aggregate jacoco.exec
worked by invoking the aggregate-report goal. Then I ran check after
disabling the code that causes check to explicitly refuse to run over pom
type projects. It seemed like it worked however it returned success despite
obviously failing the requirements, so something is not right.

I will take a look and will keep you/this pull request updated on any
improvements.

—
Reply to this email directly or view it on GitHubhttps://github.com//pull/97#issuecomment-18304557
.

http://www.linkedin.com/in/dvydra
http://www.testdriven.com
http://twitter.com/vydra

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

John Oliver added 2 commits May 22, 2013 22:47
John Oliver
Extend aggregate to checking too
10032f6
John Oliver
Remove redundant method
2d27b7d
@johnoliver

johnoliver commented May 22, 2013

Copy link
Copy Markdown
Author

@vydra I have updated to include the check goal.

See how I configured it at:

https://github.com/johnoliver/mvn-multi-module-web-with-jacoco-it/

running the following seemed to work fine

mvn clean package org.jacoco:jacoco-maven-plugin:0.6.3-SNAPSHOT:aggregate-report org.jacoco:jacoco-maven-plugin:0.6.3-SNAPSHOT:check

There are a few problem with this at the moment, first is that aggregate-report is needed to be run as this is what is doing the aggregation. If people feel it is likely that people will want the check functionality independent of the report then I can look at refactoring out the aggregation part to share between the two goals.

Second is that the aggregation has to be specified as a goal rather than bound to a lifecycle in the pom. This is since if it gets executed as part of a lifecycle the aggregation will be executed before the reactor projects, thus aggregating nothing. It is possible there may be work arounds for this such as the process described in: http://blog.sonatype.com/people/2009/05/how-to-make-a-plugin-run-once-during-a-build/

Otherwise let me know if this works.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@scottcarey

scottcarey commented Dec 3, 2013

Copy link
Copy Markdown

My most needed feature. It would be good to have both transitive coverage and project-only coverage, but if I had the choice of only one, it would be transitive.

Its been 6 months, any update or resolution for this feature?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@johnoliver

johnoliver commented Dec 3, 2013

Copy link
Copy Markdown
Author

Given that the maven merge goal was accepted recently but is not yet released (See https://github.com/jacoco/jacoco/blob/master/jacoco-maven-plugin/src/org/jacoco/maven/MergeMojo.java). My guess is this pull request will not be accepted as there is a significant amount of overlap with that Mojo. I am not sure with the merge mojo if there is an intended way of going full cycle from module coverage-> merged exec file -> aggregate-report or if that is going to require an additional mojo on top. My guess is it will require multiple calls to maven i.e:

mvn test
mvn jacoco:merge
mvn report -DdataFile=./jacoco.exec

Using merge does not address the issue of cross module coverage, only producing an aggregated report but now that code exists it should be reused here when producing cross module coverage too.

Again I am willing to do the work to update this pull request to reuse the code from the merge goal, but there seems to have been little enthusiasm for merging this pull request in general.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@melloware

melloware commented Dec 3, 2013

Copy link
Copy Markdown

This is a desperately needed feature that other code coverage tools like Clover have. I really hope they re-consider and add this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mmakowski

mmakowski commented Jan 17, 2014

Copy link
Copy Markdown

I would also ask either for this to be merged or for instructions how to achieve equivalent functionality with existing maven plugin. We currently maintain a fork of JaCoCo with this patch applied but would rather use the official releases.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost ghost assigned mfriedenhagen Jan 17, 2014
@mfriedenhagen

mfriedenhagen commented Jan 20, 2014

Copy link
Copy Markdown
Member

@johnoliver et al.: I try to describe the usecase:

  • Given
    • I have a multi-module Maven project with a root-POM and
    • I have specified jacoco:aggregate-report on root-POM level to be run during phase verify
  • When
    • I execute mvn clean verify on root-POM level
  • Then
    • I expect all tests and integration tests to be run firstly in the single modules 1-N collecting their individual coverage in their respective ${reactorbase}/module[1-N]/target/jacoco.exec and reports to be generated in ${reactorbase}/module[1-N]/target/site/jacoco/ and
    • I expect an aggregated report in ${reactorbase}/target/site/jacoco and
    • I expect the check goal (check-aggregate?) to check the overall coverage.

Is this the usecase?

Since jacoco-0.6.4 you may differentiate between coverage coming from unit and integration tests, see prepare-agent-integration and report-integration.
Should these be integrated as well?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mfriedenhagen

mfriedenhagen commented Jan 20, 2014

Copy link
Copy Markdown
Member

Sample how to achieve run when the last module hits aggregate-report: install:install will delay installation until the last reactor project reaches install phase.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@johnoliver

johnoliver commented Jan 20, 2014

Copy link
Copy Markdown
Author

This is part of the use case, which is the merging of multiple reports into one aggregated report, however I believe you have already addressed this issue partially with the MergeMojo but as I said before I am unsure if you need an extra step to then report on the merged exec file.

But the additional use case that is very critical, is counting coverage from tests that are outside of the module that a class is defined. As I mentioned in the original description if a test in module A covers code in module B, I want the report to count those lines in module B as covered. Currently (or at least at the time this pull request was made), jacoco would only report on code that was inside the same module as the test.

Again I am willing to update this pull request to reuse the MergeMojo to prevent duplicated functionality, provided it is accepted that this is a use case you want to cover and are willing to merge an acceptable pull request on the matter. Given the number of people that have requested this feature it seems like one that should be addressed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@marchof

marchof commented Jan 21, 2014

Copy link
Copy Markdown
Member

Some random thoughts:

  • JaCoCo build itself is a possible example for a aggregate report
  • We might need includemudules/excludemodules properties to specify the projects which should be aggregated. Especially in the case where test code is in different module one would probably not expect the test code in the report.
  • Instead of defining a new goal we might configure the existing report goal.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@smaring

smaring commented Dec 31, 2015

Copy link
Copy Markdown

+1 ... we would like to see this as well. We are currently aggregating in Sonarqube, but our developers don't want to have to publish to Sonar in order to see the aggregate coverage on the their multi-module projects, and we also publish our sites and that's the one missing report at the top level for those. Why has John's pull request been sitting open for so long? We left Cobertura because it was starting to feel like a dead project ... and now this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JLLeitschuh

JLLeitschuh commented Jan 2, 2016

Copy link
Copy Markdown

WORKAROUND

Put this in your build.gradle after your project and allProjects declarations:

/*
 * This is roughly based upon this post:
 * https://discuss.gradle.org/t/merge-jacoco-coverage-reports-for-multiproject-setups/12100/6
 */
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
    description = 'Generates an aggregate report from all subprojects'
    dependsOn(subprojects.test)

    additionalSourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs)
    sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
    classDirectories = files(subprojects.sourceSets.main.output)
    executionData = files(subprojects.jacocoTestReport.executionData)

    reports {
        html.enabled = true
        xml.enabled = true
    }

    doFirst {
        executionData = files(executionData.findAll { it.exists() })
    }
}
check.dependsOn jacocoRootReport
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ksperling

ksperling commented Jan 19, 2016

Copy link
Copy Markdown

Would be really good to have this feature. As a workaround, I'm currently using a groovy script with the GMaven plugin (groovy-maven-plugin:execute). The script is executed from a separate 'aggregate' module and combines coverage data for all projects that are part of the reactor build: https://gist.github.com/ksperling/57b81ea723e319967d24

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@btaz

btaz commented Jan 21, 2016

Copy link
Copy Markdown

+1

This feature is badly needed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bobkubista

bobkubista commented Feb 9, 2016

Copy link
Copy Markdown

+1

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vivekkumar71 vivekkumar71 mentioned this pull request Feb 12, 2016
Trying to Implement code coverage aggregator in sonar qube for Multimodel project #375
Closed
@overheadhunter

overheadhunter commented Feb 13, 2016

Copy link
Copy Markdown

+1

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zxiiro

zxiiro commented Feb 13, 2016

Copy link
Copy Markdown

I'm disappointed that there are so many +1's on this PR yet it appears there is no progress. What do we need to do to get this going forward?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markuskreusch

markuskreusch commented Feb 14, 2016

Copy link
Copy Markdown

+1

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jawaharprasad

jawaharprasad commented Feb 16, 2016

Copy link
Copy Markdown

Not sure why this is not merged yet.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sideisra

sideisra commented Feb 17, 2016

Copy link
Copy Markdown

+1

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

johnoliver added 5 commits February 20, 2016 14:00
@johnoliver
Merge branch 'master' of https://github.com/jacoco/jacoco into upstre…
95a8c4d
…am-tracker
@johnoliver
Merge with 0.7.7-SNAPSHOT.
4ee28bd
Extract exec file merging logic from MergeMojo into ExecFileMerger and reuse the common code from ReportAggregateMojo.
@johnoliver
Reduce number of merge changes
7ed1269
@johnoliver
Further reduce number of merge changes
22d8fde
@johnoliver
Allow MergeMojo to work on pom only projects
2edb04f
@johnoliver

johnoliver commented Feb 20, 2016

Copy link
Copy Markdown
Author

For those interested I have updated the pull request to have merged with the latest 0.7.7-SNAPSHOT. So if you are using this patch you can upgrade to the latest version.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@subhodipp

subhodipp commented Feb 24, 2016

Copy link
Copy Markdown

@johnoliver Can you please let me know how to generate this without ant support?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RadoslawOsinski

RadoslawOsinski commented Feb 29, 2016

Copy link
Copy Markdown

It looks as maven plugin is stuck for few years on simple problem. Do not get me wrong. I appreciate your work. Especialy "johnoliver" who tries to merge this feature. But in the meantime people are migrating to gradle which is growing faster. In example look at this link:
https://gist.github.com/aalmiray/e6f54aa4b3803be0bcac
Gradle users are solving problems in days instead of years.

+1 for merging this feature.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kriazhev

kriazhev commented Mar 10, 2016

Copy link
Copy Markdown

+1

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JLLeitschuh

JLLeitschuh commented Mar 16, 2016

Copy link
Copy Markdown

Dear god, people, please, stop using +1.
There's a new reaction system for that sort of thing.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Donnerbart

Donnerbart commented Mar 16, 2016

Copy link
Copy Markdown

This request is so ancient (nevertheless important) that it doesn't deserve such a modern reaction system. The solution is to fix the issue, not to make the +1 less painful.

mapoulin, khmarbaise, StefanPenndorf, bkmeneguello, and ansell reacted with thumbs up emoji
All reactions
  • 👍 5 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@marchof marchof mentioned this pull request Mar 22, 2016
Aggregate Report Maven Goal #388
Merged
@marchof

marchof commented Mar 22, 2016

Copy link
Copy Markdown
Member

@johnoliver @Godin @mfriedenhagen
I finally found some time to dive into this issue and did a detailed analysis of the issue together with @jwloka. We discussed different solutions and finally implemented a different approach in PR #388.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@marchof marchof mentioned this pull request Mar 23, 2016
added support for multi-module projects #336
Closed
@marchof

marchof commented Apr 19, 2016

Copy link
Copy Markdown
Member

Fixed with #388.

overheadhunter and ansell reacted with hooray emoji
All reactions
  • 🎉 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@marchof marchof closed this Apr 19, 2016
@Godin Godin modified the milestones: 0.7.7, Maven multi-module projects Jun 10, 2016
@jacoco jacoco locked and limited conversation to collaborators Jan 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@Godin Godin

Labels

component: maven jacoco-maven-plugin type: enhancement

Projects

None yet

Milestone

0.7.7

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

20 participants

@johnoliver @melloware @vydra @scottcarey @mmakowski @mfriedenhagen @marchof @hhimanshu @alborworld @efisant @scosenza @bobfields @flozano @Lucas3oo @SierraGolf @vauvenal5 @Zlika @maeda @opajonk @dputman
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.