Search in sources :

Example 1 with Report

use of org.gradle.api.reporting.Report in project gradle by gradle.

the class BuildDashboardGenerator method generate.

private void generate(final HtmlPageBuilder<Writer> builder) {
    final String baseCssLink = builder.requireResource(getClass().getResource("/org/gradle/reporting/base-style.css"));
    final String cssLink = builder.requireResource(getClass().getResource("style.css"));
    new Html(builder.getOutput()) {

        {
            html();
            head();
            meta().httpEquiv("Content-Type").content("text/html; charset=utf-8");
            meta().httpEquiv("x-ua-compatible").content("IE=edge");
            link().rel("stylesheet").type("text/css").href(baseCssLink).end();
            link().rel("stylesheet").type("text/css").href(cssLink).end();
            title().text("Build dashboard").end();
            end();
            body();
            div().id("content");
            if (reports.size() > 0) {
                h1().text("Build reports").end();
                ul();
                for (Report report : reports) {
                    li();
                    if (report.getDestination().exists()) {
                        a().href(GFileUtils.relativePath(outputFile.getParentFile(), getHtmlLinkedFileFromReport(report))).text(report.getDisplayName());
                    } else {
                        span().classAttr("unavailable").text(report.getDisplayName());
                    }
                    end(2);
                }
                end();
            } else {
                h1().text("There are no build reports available.").end();
            }
            div().id("footer");
            p();
            text("Generated by ");
            a().href("http://www.gradle.org").text(GradleVersion.current().toString()).end();
            text(" at " + builder.formatDate(new Date()));
            end();
            end();
            end();
            endAll();
        }
    };
}
Also used : Report(org.gradle.api.reporting.Report) DirectoryReport(org.gradle.api.reporting.DirectoryReport) Html(com.googlecode.jatl.Html)

Example 2 with Report

use of org.gradle.api.reporting.Report in project gradle by gradle.

the class JacocoPlugin method addDefaultReportTask.

private void addDefaultReportTask(final JacocoPluginExtension extension, final Test task) {
    final JacocoReport reportTask = project.getTasks().create("jacoco" + StringUtils.capitalize(task.getName()) + "Report", JacocoReport.class);
    reportTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
    reportTask.setDescription(String.format("Generates code coverage report for the %s task.", task.getName()));
    reportTask.executionData(task);
    reportTask.sourceSets(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main"));
    ConventionMapping taskMapping = ((IConventionAware) reportTask).getConventionMapping();
    taskMapping.getConventionValue(reportTask.getReports(), "reports", false).all(new Action<Report>() {

        @Override
        public void execute(final Report report) {
            ConventionMapping reportMapping = ((IConventionAware) report).getConventionMapping();
            // reportMapping.map('enabled', Callables.returning(true));
            if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) {
                reportMapping.map("destination", new Callable<File>() {

                    @Override
                    public File call() {
                        return new File(extension.getReportsDir(), task.getName() + "/" + report.getName());
                    }
                });
            } else {
                reportMapping.map("destination", new Callable<File>() {

                    @Override
                    public File call() {
                        return new File(extension.getReportsDir(), task.getName() + "/" + reportTask.getName() + "." + report.getName());
                    }
                });
            }
        }
    });
}
Also used : JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) JacocoReport(org.gradle.testing.jacoco.tasks.JacocoReport) Report(org.gradle.api.reporting.Report) ConventionMapping(org.gradle.api.internal.ConventionMapping) IConventionAware(org.gradle.api.internal.IConventionAware) File(java.io.File) JacocoReport(org.gradle.testing.jacoco.tasks.JacocoReport) Callable(java.util.concurrent.Callable)

Example 3 with Report

use of org.gradle.api.reporting.Report in project gradle by gradle.

the class BuildDashboardGenerator method render.

@Override
public void render(Collection<Report> reports, final File outputFile) {
    this.reports = new TreeSet<Report>(new Comparator<Report>() {

        public int compare(Report o1, Report o2) {
            return o1.getDisplayName().compareTo(o2.getDisplayName());
        }
    });
    this.reports.addAll(reports);
    this.outputFile = outputFile;
    HtmlReportRenderer renderer = new HtmlReportRenderer();
    renderer.renderRawSinglePage(reports, new ReportRenderer<Collection<Report>, HtmlPageBuilder<Writer>>() {

        @Override
        public void render(Collection<Report> model, HtmlPageBuilder<Writer> builder) throws IOException {
            generate(builder);
        }
    }, outputFile);
}
Also used : Report(org.gradle.api.reporting.Report) DirectoryReport(org.gradle.api.reporting.DirectoryReport) HtmlPageBuilder(org.gradle.reporting.HtmlPageBuilder) IOException(java.io.IOException) HtmlReportRenderer(org.gradle.reporting.HtmlReportRenderer) Writer(java.io.Writer)

Aggregations

Report (org.gradle.api.reporting.Report)3 DirectoryReport (org.gradle.api.reporting.DirectoryReport)2 Html (com.googlecode.jatl.Html)1 File (java.io.File)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1 Callable (java.util.concurrent.Callable)1 ConventionMapping (org.gradle.api.internal.ConventionMapping)1 IConventionAware (org.gradle.api.internal.IConventionAware)1 JavaPluginConvention (org.gradle.api.plugins.JavaPluginConvention)1 HtmlPageBuilder (org.gradle.reporting.HtmlPageBuilder)1 HtmlReportRenderer (org.gradle.reporting.HtmlReportRenderer)1 JacocoReport (org.gradle.testing.jacoco.tasks.JacocoReport)1