How to use `jacoco-report-aggregation` plugin in a Gradle multi module project?

The source code is here: GitHub - yvasyliev/telegram-forwarder-bot at feature/multimodule

I have a Gradle multi module project. The sub-modules are:

  • telegram-forwarder-bot (a console application)
  • telegram-forwarder-starter (library)
  • telegram-forwarder-starter-logging (library)
  • telegram-forwarder-starter-reddit (library)
  • telegram-forwarder-starter-thymeleaf (library)

jacoco plugin is applied to all sub modules and JaCoCo report generation works as expected in each submodule.

Now I want to aggregate JaCoCo reports from submodules in a single report.

I applied jacoco-report-aggregation plugin and added the following code to the root build.gradle:

plugins {
    id 'jacoco-report-aggregation'
}

dependencies {
    jacocoAggregation project(':telegram-forwarder-bot')
}

reporting {
    reports {
        testCodeCoverageReport(JacocoCoverageReport) {
            testSuiteName = "test"
        }
    }
}

When I try to execute ./gradlew testCodeCoverageReport, I’m getting the following error:

[Incubating] Problems report is available at: file:///C:/Users/Yevhen/IdeaProjects/reddit-telegram-forwarder/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':testCodeCoverageReport'.
> Could not resolve all dependencies for configuration ':aggregateCodeCoverageReportResults'.
   > Could not resolve project :telegram-forwarder-bot.
     Required by:
         root project :
      > Unable to find a matching variant of root project ::
          - No variants exist.

* Try:
> Creating consumable variants is explained in more detail at https://docs.gradle.org/8.14.3/userguide/declaring_dependencies.html#sec:resolvable-consumable-configs.
> Review the variant matching algorithm at https://docs.gradle.org/8.14.3/userguide/variant_attributes.html#sec:abm_algorithm.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 3s

Could you please help me to make jacoco-report-aggregation plugin work?

You follow many bad roads and highly discouraged bad practices.
But your main problem here is, that your root project and one of your subprojects have the same name, telegram-forwarder-bot.
This seems to confuse Gradle and makes it confuse those two projects when resolving.