use of org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Writer in project maven-plugins by apache.
the class AbstractInvokerMojo method writeBuildReport.
/**
* Writes the XML report for the specified build job unless report generation has been disabled.
*
* @param buildJob The build job whose report should be written, must not be <code>null</code>.
* @throws org.apache.maven.plugin.MojoExecutionException If the report could not be written.
*/
private void writeBuildReport(BuildJob buildJob) throws MojoExecutionException {
if (disableReports) {
return;
}
String safeFileName = buildJob.getProject().replace('/', '_').replace('\\', '_').replace(' ', '_');
if (safeFileName.endsWith("_pom.xml")) {
safeFileName = safeFileName.substring(0, safeFileName.length() - "_pom.xml".length());
}
File reportFile = new File(reportsDirectory, "BUILD-" + safeFileName + ".xml");
try {
FileOutputStream fos = new FileOutputStream(reportFile);
try {
Writer osw = new OutputStreamWriter(fos, buildJob.getModelEncoding());
BuildJobXpp3Writer writer = new BuildJobXpp3Writer();
writer.write(osw, buildJob);
osw.close();
} finally {
fos.close();
}
} catch (IOException e) {
throw new MojoExecutionException("Failed to write build report " + reportFile, e);
}
}
Aggregations