Is it possible - in a multi-project - to aggregate...
# general
d
Is it possible - in a multi-project - to aggregate all junit xml files to rootProject.buildDir/reports? Just setting outputLocation of the xml files just replaces the directory each test that finishes. The AggregateTestReport and TestReport tasks both seems to deal with HTML only.
v
Don't ever use overlapping outputs for tasks like generating files into the same directory while the directory is the output. This disturbs up-to-date checks, proper caching and so on. Have a look at the test-report-aggregation plugin, it does exactly what you want. And if you want to share other things cross-project, you should read https://docs.gradle.org/current/userguide/cross_project_publications.html
d
Unfortunately it does not,
The Test Report Aggregation plugin (plugin id: test-report-aggregation) provides tasks and configurations used to aggregate the results of multiple Test task invocations (potentially spanning multiple Gradle projects) into a single HTML report
...what I'm interested in is the JUnit XML files. I opted for solving it via:
Copy code
withType(Test::class.java) {
	doLast {
		copy {
			val reportDir = reports.junitXml.outputLocation.get()
			from(reports.junitXml.outputLocation)
			into(rootProject.buildDir.resolve(reportDir.asFile.relativeTo(buildDir)))
		}
	}
}
Should probably make it conditional if running under CI, but something along those lines. Is there any drawbacks to my solution? The CI starts off with a non-existing build directory every time.
v
The task puts them in a html report. But the report works on the JUnit XML files. And those you can get from the configuration it creates.
Read the link I gave you, there the principle is explained
👍 1
And those plugins solve it like that
The individual projects publish the generated files, the root project collects them properly by using a configuration with accordingly set attributes
So if you need the files for something else, just use the configuration
d
Aha, I thought you meant that test-report-aggregation plugin supported XML files.
v
Well it aggregates the XML files for you in the configuration. 🙂
👍 1
d
Aha, so while it only generates a combined HTML report, you can have something that depends on that aggregated task, and finds the input nodes that will give you a ref to the XML files?
Is it perhaps the same thing with the new aggregated coverage task? That it only generates an aggregated HTML report, but you could create something that depends on it and rips out the jexec data files for proper merging?
v
Exactly. You don't need it should depend on the report tasks or "rip out information". Just as it said, use the configurations those plugins add, they contain the files.
d
Cool, turns out that I didn't need it in the end, but for coverage it's a different matter. There I do want to merge the exec files for further external processing.
Thanks.
👌 1