Search in sources :

Example 16 with MavenReportException

use of org.apache.maven.reporting.MavenReportException in project maven-plugins by apache.

the class JavadocReport method doExecute.

/** {@inheritDoc} */
public void doExecute() throws MojoExecutionException, MojoFailureException {
    if (skip) {
        getLog().info("Skipping javadoc generation");
        return;
    }
    try {
        RenderingContext context = new RenderingContext(outputDirectory, getOutputName() + ".html");
        SiteRendererSink sink = new SiteRendererSink(context);
        Locale locale = Locale.getDefault();
        generate(sink, locale);
    } catch (MavenReportException e) {
        failOnError("An error has occurred in " + getName(Locale.ENGLISH) + " report generation", e);
    } catch (RuntimeException e) {
        failOnError("An error has occurred in " + getName(Locale.ENGLISH) + " report generation", e);
    }
}
Also used : Locale(java.util.Locale) RenderingContext(org.apache.maven.doxia.sink.render.RenderingContext) SiteRendererSink(org.apache.maven.doxia.siterenderer.sink.SiteRendererSink) MavenReportException(org.apache.maven.reporting.MavenReportException)

Example 17 with MavenReportException

use of org.apache.maven.reporting.MavenReportException 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 18 with MavenReportException

use of org.apache.maven.reporting.MavenReportException in project maven-plugins by apache.

the class AbstractJavadocMojo method collectOfflineLinks.

private Set<OfflineLink> collectOfflineLinks() throws MavenReportException {
    Set<OfflineLink> result = new LinkedHashSet<OfflineLink>();
    OfflineLink javaApiLink = getDefaultJavadocApiLink();
    if (javaApiLink != null) {
        result.add(javaApiLink);
    }
    if (includeDependencySources) {
        try {
            resolveDependencyBundles();
        } catch (IOException e) {
            throw new MavenReportException("Failed to resolve javadoc bundles from dependencies: " + e.getMessage(), e);
        }
        if (isNotEmpty(dependencyJavadocBundles)) {
            for (JavadocBundle bundle : dependencyJavadocBundles) {
                JavadocOptions options = bundle.getOptions();
                if (options != null && isNotEmpty(options.getOfflineLinks())) {
                    result.addAll(options.getOfflineLinks());
                }
            }
        }
    }
    if (this.offlineLinks != null && this.offlineLinks.length > 0) {
        result.addAll(Arrays.asList(this.offlineLinks));
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) JavadocBundle(org.apache.maven.plugin.javadoc.resolver.JavadocBundle) JavadocOptions(org.apache.maven.plugin.javadoc.options.JavadocOptions) IOException(java.io.IOException) OfflineLink(org.apache.maven.plugin.javadoc.options.OfflineLink) MavenReportException(org.apache.maven.reporting.MavenReportException)

Example 19 with MavenReportException

use of org.apache.maven.reporting.MavenReportException in project maven-plugins by apache.

the class AbstractCheckstyleReport method executeReport.

/** {@inheritDoc} */
public void executeReport(Locale locale) throws MavenReportException {
    checkDeprecatedParameterUsage(sourceDirectory, "sourceDirectory", "sourceDirectories");
    checkDeprecatedParameterUsage(testSourceDirectory, "testSourceDirectory", "testSourceDirectories");
    locator.addSearchPath(FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath());
    locator.addSearchPath("url", "");
    locator.setOutputDirectory(new File(project.getBuild().getDirectory()));
    // for when we start using maven-shared-io and maven-shared-monitor...
    // locator = new Locator( new MojoLogMonitorAdaptor( getLog() ) );
    // locator = new Locator( getLog(), new File( project.getBuild().getDirectory() ) );
    ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        CheckstyleExecutorRequest request = createRequest().setLicenseArtifacts(collectArtifacts("license")).setConfigurationArtifacts(collectArtifacts("configuration")).setOmitIgnoredModules(omitIgnoredModules);
        CheckstyleResults results = checkstyleExecutor.executeCheckstyle(request);
        ResourceBundle bundle = getBundle(locale);
        generateReportStatics();
        generateMainReport(results, bundle);
        if (enableRSS) {
            CheckstyleRssGeneratorRequest checkstyleRssGeneratorRequest = new CheckstyleRssGeneratorRequest(this.project, this.getCopyright(), outputDirectory, getLog());
            checkstyleRssGenerator.generateRSS(results, checkstyleRssGeneratorRequest);
        }
    } catch (CheckstyleException e) {
        throw new MavenReportException("Failed during checkstyle configuration", e);
    } catch (CheckstyleExecutorException e) {
        throw new MavenReportException("Failed during checkstyle execution", e);
    } finally {
        //be sure to restore original context classloader
        Thread.currentThread().setContextClassLoader(currentClassLoader);
    }
}
Also used : CheckstyleResults(org.apache.maven.plugins.checkstyle.exec.CheckstyleResults) CheckstyleRssGeneratorRequest(org.apache.maven.plugins.checkstyle.rss.CheckstyleRssGeneratorRequest) CheckstyleExecutorRequest(org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorRequest) CheckstyleExecutorException(org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorException) ResourceBundle(java.util.ResourceBundle) CheckstyleException(com.puppycrawl.tools.checkstyle.api.CheckstyleException) File(java.io.File) MavenReportException(org.apache.maven.reporting.MavenReportException)

Example 20 with MavenReportException

use of org.apache.maven.reporting.MavenReportException in project maven-plugins by apache.

the class AbstractCheckstyleReport method getListener.

/**
     * Creates and returns the report generation listener.
     *
     * @return The audit listener.
     * @throws MavenReportException If something goes wrong.
     */
protected AuditListener getListener() throws MavenReportException {
    AuditListener listener = null;
    if (StringUtils.isNotEmpty(outputFileFormat)) {
        File resultFile = outputFile;
        OutputStream out = getOutputStream(resultFile);
        if ("xml".equals(outputFileFormat)) {
            listener = new XMLLogger(out, true);
        } else if ("plain".equals(outputFileFormat)) {
            listener = new DefaultLogger(out, true);
        } else {
            // TODO: failure if not a report
            throw new MavenReportException("Invalid output file format: (" + outputFileFormat + "). Must be 'plain' or 'xml'.");
        }
    }
    return listener;
}
Also used : XMLLogger(com.puppycrawl.tools.checkstyle.XMLLogger) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) AuditListener(com.puppycrawl.tools.checkstyle.api.AuditListener) File(java.io.File) DefaultLogger(com.puppycrawl.tools.checkstyle.DefaultLogger) MavenReportException(org.apache.maven.reporting.MavenReportException)

Aggregations

MavenReportException (org.apache.maven.reporting.MavenReportException)48 File (java.io.File)23 IOException (java.io.IOException)23 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)14 ArrayList (java.util.ArrayList)10 Artifact (org.apache.maven.artifact.Artifact)7 FileOutputStream (java.io.FileOutputStream)6 Locale (java.util.Locale)6 BootclasspathArtifact (org.apache.maven.plugin.javadoc.options.BootclasspathArtifact)6 DocletArtifact (org.apache.maven.plugin.javadoc.options.DocletArtifact)6 JavadocPathArtifact (org.apache.maven.plugin.javadoc.options.JavadocPathArtifact)6 ResourcesArtifact (org.apache.maven.plugin.javadoc.options.ResourcesArtifact)6 TagletArtifact (org.apache.maven.plugin.javadoc.options.TagletArtifact)6 FileNotFoundException (java.io.FileNotFoundException)5 Writer (java.io.Writer)5 LinkedHashSet (java.util.LinkedHashSet)5 SiteRendererSink (org.apache.maven.doxia.siterenderer.sink.SiteRendererSink)5 OutputStreamWriter (java.io.OutputStreamWriter)4 MalformedURLException (java.net.MalformedURLException)3 HashMap (java.util.HashMap)3