I' working on a multi-module project that employs a standalone sub-project to aggregate coverage reports. The project is build using Gradle so it uses Jacoco report aggregation plugin for Gradle.
Currently, the coverage report is generated in HTML format only. However, I specifically need the XML file format so that I can incorporate it into an artifact within Azure DevOps pipeline.
The root project and sub-projects have the following build.grade
configuration files:
Root project
plugins {
id 'java'
}
sourceCompatibility = '17'
allprojects {
repositories {
mavenCentral()
}
tasks.withType(Test.class).tap {
configureEach {
useJUnitPlatform()
}
}
}
One of the sub-projects
plugins {
id 'java'
id 'jacoco'
}
dependencies {
...
}
The standalone coverage sub-project
plugins {
id 'java'
id 'jacoco-report-aggregation'
}
bootJar {
enabled = false
}
jar {
enabled = false
}
dependencies {
jacocoAggregation project(':sub-project1')
jacocoAggregation project(':sub-project2')
}
The root project settings.gradle
file, just for completeness:
rootProject.name = 'my root project'
include 'sub-project1'
include 'sub-project2'
include 'coverage'
To generate the reports I'm using the following Gradle command:
> gradle clean build jacocoTestReport
In a different project with no sub-projects, I was able to generate the XML file by configuring up the Jacoco plugin report like this:
build.grade
jacocoTestReport {
reports {
xml.required = true
csv.required = false
}
Yet I haven't be able to generate the XML format so far, for the multi-module project.
Any suggestions or clues wild be greatly appreciated.