Skip to content

Add a new Mojo ("report-aggregate-all") to aggregate projects from reactor without forking a lifecycle #1692

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

olamy
Copy link

@olamy olamy commented Aug 24, 2024

  • Add option to aggregate automatically reports from aggregators, no need to add any dependency

Actually having some aggregated report, need to have a module and include all dependencies of the current project.
This doesn't scale very well for large projects (Jetty can have up to more than 300 modules, we can't really add and maintain a pom with all other modules included)

@olamy
Copy link
Author

olamy commented Aug 27, 2024

@Godin Hi any chance to get this merged and released?

@@ -38,6 +38,11 @@
<groupId>${project.groupId}</groupId>
<artifactId>org.jacoco.agent.rt</artifactId>
</dependency>
<dependency>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with recent version of Maven this can be build before the maven plugin, so need to be sure the maven plugin is build first.

* @since 0.8.13
*/
@Parameter(defaultValue = "false", property = "jacoco.onlyReactorProjects")
private boolean onlyReactorProjects;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this property called only... and not all...?

From the javadoc seems more appropriate to call it allReactorProjects, or perhaps allModules or allSubModules?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not really sure because the code currently reads only all dependencies declared in the coverage/aggregator project (dependencies that are part of the reactor).
If the flag is activated, the code will not use any current protect dependencies but only(All :))ReactorProjects.
So yes, something like allReactorProjects would also work, except it doesn't tell the user the configuration no longer reads the project's dependencies.
Doh, this looks complicated to explain so that it might be wrong :).

no real strong opinion. @Godin what do you think?

@olamy olamy force-pushed the report-aggregate-reactors-auto branch from 44082a5 to 59f7f5e Compare September 25, 2024 08:35
@olamy
Copy link
Author

olamy commented Sep 25, 2024

@Godin ping

@olamy
Copy link
Author

olamy commented Oct 29, 2024

@Godin any chance to have this merged or at least some comments on why this cannot be merged?
Thanks

@cpfeiffer
Copy link

cpfeiffer commented Nov 12, 2024

Thanks a lot, we had a similar thing in mind. However, I would like to suggest creating a new mojo for this, and making it an aggregator mojo (aggregator = true).

Reason: when adding the goal to a maven command like this:

mvn clean
mvn verify jacoco:report-aggregate

you will successfully get a toplevel jacoco-report that includes all modules, however with no content at all. This is because
non-aggregator mojos are integrated into the normal build lifecycle. So the report for the toplevel module will be created before any coverage has been calculated for the modules.

Even worse, if you call

mvn clean verify jacoco:report-aggregate

you do get coverage, alas, the coverage of the previous build, because clean is also integrated into the lifecycle. So when report-aggregate is executed on the parent, it will find the old *.exec files of the child modules, because they have not been cleaned, yet.

A dedicated aggregator-mojo OTOH will be executed after the lifecycle:

mvn clean verify jacoco:report-aggregate-all

This would also remove the need for the onlyReactorProjects property.

@olamy olamy force-pushed the report-aggregate-reactors-auto branch 2 times, most recently from 15643fc to 3d89803 Compare December 11, 2024 08:38
@olamy olamy force-pushed the report-aggregate-reactors-auto branch from 3d89803 to b49af0d Compare February 7, 2025 09:18
@olamy olamy changed the title Add a configuration to aggregate automatically projects from reactor (no need to declare manually all depdencies) Add a new Mojo to aggregate projects from reactor without forking a lifecycle Feb 17, 2025
@olamy olamy changed the title Add a new Mojo to aggregate projects from reactor without forking a lifecycle Add a new Mojo ("report-aggregate-all") to aggregate projects from reactor without forking a lifecycle Feb 17, 2025
@olamy
Copy link
Author

olamy commented Feb 17, 2025

@cpfeiffer Sorry for delay, I forgot this one. The changes should be better.
I have been testing it on large projects such as Jetty codebase and Cometd.

@cpfeiffer
Copy link

Awesome! Would it be good practice to let ReportAggregateAllMojo inherit ReportAggregateMojo and just overriding the findDependencies() (to be made protected then)?

@olamy
Copy link
Author

olamy commented Feb 19, 2025

Awesome! Would it be good practice to let ReportAggregateAllMojo inherit ReportAggregateMojo and just overriding the findDependencies() (to be made protected then)?

Oh right. good catch, 2 ezy. Just pushed it.

@cpfeiffer
Copy link

Excellent, thanks a lot! ❤️
So what do the the jacoco maintainers think?

@olamy
Copy link
Author

olamy commented Feb 19, 2025

@Godin ping :)

@olamy
Copy link
Author

olamy commented Mar 11, 2025

sadly, this doesn't look to attract any attention from the maintainer of the jacoco plugin.
Not sure why, as it's a real missing feature.
I will have to create a separate Maven plugin with only this single mojo. BTW a bit different as I will not be able to use exact same code which extends a mojo from here.

@cpfeiffer
Copy link

sadly, this doesn't look to attract any attention from the maintainer of the jacoco plugin. Not sure why, as it's a real missing feature. I will have to create a separate Maven plugin with only this single mojo. BTW a bit different as I will not be able to use exact same code which extends a mojo from here.

I hope it's just a time-issue.
This fix would make a whole wiki-section of discussion/workarounds obsolete. I would be willing to update it. What do you think, @Godin ?

@olamy
Copy link
Author

olamy commented Mar 11, 2025

Maybe a timing issue for an idea/PR started 6 months ago...

@olamy
Copy link
Author

olamy commented Mar 14, 2025

@cpfeiffer If you are interested, I have done this https://github.com/olamy/jacoco-aggregator-maven-plugin/
It's not the best solution, but after more than six months and no comment from here, I guess there is no interest.
I will leave the PR open just in case.

@marchof
Copy link
Member

marchof commented Mar 14, 2025

Dear @olamy, thanks for your contribution and very sorry for the silence from us maintainers. We (especially @Godin) mostly spend our spare time in keeping the core up-to-date. Due to our limited resources we're very reluctant to add new features which requires even more maintenance. Especially maintaining the Maven plugin is very exhausting as many community members have a strong opinion how things are done (at least in their context). We were already at the point to give-up on the integrations so that that the community can start separate projects.

Questions: Can you imagine to help us with the maintenance (bug fixing, feature/bug triage etc) for the Maven goals in the long run?

@olamy
Copy link
Author

olamy commented Mar 15, 2025

@marchof, thanks for your comment and for answering a big part of my frustration :)
No worries. I perfectly understand you may have limited time for maintenance.
I am happy to help maintain the Maven plugin part, as I may have some experience doing so.
Thanks

Signed-off-by: Olivier Lamy <[email protected]>
@olamy olamy force-pushed the report-aggregate-reactors-auto branch from 92528e1 to d54fdda Compare March 15, 2025 01:15
@olamy
Copy link
Author

olamy commented Apr 2, 2025

@marchof @Godin thanks guys for your help and merge it for the last release 0.8.13.
very good community support here.........

@marchof
Copy link
Member

marchof commented Apr 3, 2025

@olamy As I explained above we prioritize maintenance and regular lifecycle tasks over new features. As Java 24 was released we had a strong demand by the community to have released JaCoCo version which support the latest Java release.

Spending spare time on a free project only works in a friendly and respectful environment. While I understand your frustration that we haven't found time to review your PR I politely request to refrain from passive agressive statements.

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

Successfully merging this pull request may close these issues.

4 participants