use of org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Reader in project maven-plugins by apache.
the class InvokerReport method executeReport.
protected void executeReport(Locale locale) throws MavenReportException {
DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale);
percentFormat = new DecimalFormat(getText(locale, "report.invoker.format.percent"), symbols);
secondsFormat = new DecimalFormat(getText(locale, "report.invoker.format.seconds"), symbols);
Sink sink = getSink();
sink.head();
sink.title();
sink.text(getText(locale, "report.invoker.result.title"));
sink.title_();
sink.head_();
sink.body();
sink.section1();
sink.sectionTitle1();
sink.text(getText(locale, "report.invoker.result.title"));
sink.sectionTitle1_();
sink.paragraph();
sink.text(getText(locale, "report.invoker.result.description"));
sink.paragraph_();
sink.section1_();
// ----------------------------------
// build buildJob beans
// ----------------------------------
File[] reportFiles = ReportUtils.getReportFiles(reportsDirectory);
if (reportFiles.length <= 0) {
getLog().info("no invoker report files found, skip report generation");
return;
}
List<BuildJob> buildJobs = new ArrayList<BuildJob>(reportFiles.length);
for (File reportFile : reportFiles) {
try {
BuildJobXpp3Reader reader = new BuildJobXpp3Reader();
buildJobs.add(reader.read(ReaderFactory.newXmlReader(reportFile)));
} catch (XmlPullParserException e) {
throw new MavenReportException("Failed to parse report file: " + reportFile, e);
} catch (IOException e) {
throw new MavenReportException("Failed to read report file: " + reportFile, e);
}
}
// ----------------------------------
// summary
// ----------------------------------
constructSummarySection(buildJobs, locale);
// ----------------------------------
// per file/it detail
// ----------------------------------
sink.section2();
sink.sectionTitle2();
sink.text(getText(locale, "report.invoker.detail.title"));
sink.sectionTitle2_();
sink.section2_();
// detail tests table header
sink.table();
sink.tableRow();
// -------------------------------------------
// name | Result | time | message
// -------------------------------------------
sinkTableHeader(sink, getText(locale, "report.invoker.detail.name"));
sinkTableHeader(sink, getText(locale, "report.invoker.detail.result"));
sinkTableHeader(sink, getText(locale, "report.invoker.detail.time"));
sinkTableHeader(sink, getText(locale, "report.invoker.detail.message"));
sink.tableRow_();
for (BuildJob buildJob : buildJobs) {
renderBuildJob(buildJob, locale);
}
sink.table_();
sink.body_();
sink.flush();
sink.close();
}
use of org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Reader in project maven-plugins by apache.
the class VerifyMojo method execute.
/**
* Invokes Maven on the configured test projects.
*
* @throws org.apache.maven.plugin.MojoExecutionException If the goal encountered severe errors.
* @throws org.apache.maven.plugin.MojoFailureException If any of the Maven builds failed.
*/
public void execute() throws MojoExecutionException, MojoFailureException {
if (skipInvocation) {
getLog().info("Skipping invocation per configuration." + " If this is incorrect, ensure the skipInvocation parameter is not set to true.");
return;
}
File[] reportFiles = ReportUtils.getReportFiles(reportsDirectory);
if (reportFiles.length <= 0) {
if (Boolean.TRUE.equals(failIfNoProjects)) {
throw new MojoFailureException("No projects to invoke!");
}
getLog().info("No invoker report files found, nothing to check.");
return;
}
InvokerSession invokerSession = new InvokerSession();
for (File reportFile : reportFiles) {
try {
BuildJobXpp3Reader reader = new BuildJobXpp3Reader();
invokerSession.addJob(reader.read(ReaderFactory.newXmlReader(reportFile)));
} catch (XmlPullParserException e) {
throw new MojoExecutionException("Failed to parse report file: " + reportFile, e);
} catch (IOException e) {
throw new MojoExecutionException("Failed to read report file: " + reportFile, e);
}
}
if (!suppressSummaries) {
invokerSession.logSummary(getLog(), ignoreFailures);
}
invokerSession.handleFailures(getLog(), ignoreFailures);
}
Aggregations