|
16 | 16 | import java.io.BufferedInputStream; |
17 | 17 | import java.io.ByteArrayInputStream; |
18 | 18 | import java.io.File; |
| 19 | +import java.io.FileOutputStream; |
19 | 20 | import java.io.IOException; |
20 | 21 | import java.io.InputStream; |
21 | 22 | import java.nio.file.Files; |
|
43 | 44 | import org.jacoco.report.IReportVisitor; |
44 | 45 | import org.jacoco.report.InputStreamSourceFileLocator; |
45 | 46 | import org.jacoco.report.html.HTMLFormatter; |
| 47 | +import org.jacoco.report.xml.XMLFormatter; |
46 | 48 | import org.slf4j.Logger; |
47 | 49 | import org.slf4j.LoggerFactory; |
48 | 50 |
|
@@ -290,12 +292,23 @@ private void dumpCoverageReport(IBundleCoverage coverageBundle, File reportFolde |
290 | 292 | } |
291 | 293 | try { |
292 | 294 | final HTMLFormatter htmlFormatter = new HTMLFormatter(); |
293 | | - final IReportVisitor visitor = |
| 295 | + |
| 296 | + final IReportVisitor htmlVisitor = |
294 | 297 | htmlFormatter.createVisitor(new FileMultiReportOutput(reportFolder)); |
295 | | - visitor.visitInfo(Collections.emptyList(), Collections.emptyList()); |
296 | | - visitor.visitBundle( |
| 298 | + htmlVisitor.visitInfo(Collections.emptyList(), Collections.emptyList()); |
| 299 | + htmlVisitor.visitBundle( |
297 | 300 | coverageBundle, new RepoIndexFileLocator(repoIndexProvider.getIndex(), repoRoot)); |
298 | | - visitor.visitEnd(); |
| 301 | + htmlVisitor.visitEnd(); |
| 302 | + |
| 303 | + File xmlReport = new File(reportFolder, "jacoco.xml"); |
| 304 | + try (FileOutputStream xmlReportStream = new FileOutputStream(xmlReport)) { |
| 305 | + XMLFormatter xmlFormatter = new XMLFormatter(); |
| 306 | + IReportVisitor xmlVisitor = xmlFormatter.createVisitor(xmlReportStream); |
| 307 | + xmlVisitor.visitInfo(Collections.emptyList(), Collections.emptyList()); |
| 308 | + xmlVisitor.visitBundle( |
| 309 | + coverageBundle, new RepoIndexFileLocator(repoIndexProvider.getIndex(), repoRoot)); |
| 310 | + xmlVisitor.visitEnd(); |
| 311 | + } |
299 | 312 | } catch (Exception e) { |
300 | 313 | LOGGER.error("Error while creating report in {}", reportFolder, e); |
301 | 314 | } |
|
0 commit comments