Search in sources :

Example 1 with BuildJobXpp3Reader

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();
}
Also used : DecimalFormatSymbols(java.text.DecimalFormatSymbols) Sink(org.apache.maven.doxia.sink.Sink) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) BuildJobXpp3Reader(org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Reader) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) BuildJob(org.apache.maven.plugins.invoker.model.BuildJob) IOException(java.io.IOException) File(java.io.File) MavenReportException(org.apache.maven.reporting.MavenReportException)

Example 2 with BuildJobXpp3Reader

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);
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) BuildJobXpp3Reader(org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Reader) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) IOException(java.io.IOException) File(java.io.File)

Aggregations

File (java.io.File)2 IOException (java.io.IOException)2 BuildJobXpp3Reader (org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Reader)2 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)2 DecimalFormat (java.text.DecimalFormat)1 DecimalFormatSymbols (java.text.DecimalFormatSymbols)1 ArrayList (java.util.ArrayList)1 Sink (org.apache.maven.doxia.sink.Sink)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 BuildJob (org.apache.maven.plugins.invoker.model.BuildJob)1 MavenReportException (org.apache.maven.reporting.MavenReportException)1