Search in sources :

Example 1 with HtmlReportRenderer

use of org.gradle.reporting.HtmlReportRenderer in project gradle by gradle.

the class DefaultTestReport method generateFiles.

private void generateFiles(AllTestResults model, final TestResultsProvider resultsProvider, File reportDir) {
    try {
        HtmlReportRenderer htmlRenderer = new HtmlReportRenderer();
        htmlRenderer.render(model, new ReportRenderer<AllTestResults, HtmlReportBuilder>() {

            @Override
            public void render(final AllTestResults model, final HtmlReportBuilder output) throws IOException {
                buildOperationProcessor.run(new Action<BuildOperationQueue<HtmlReportFileGenerator<? extends CompositeTestResults>>>() {

                    @Override
                    public void execute(BuildOperationQueue<HtmlReportFileGenerator<? extends CompositeTestResults>> queue) {
                        queue.add(generator("index.html", model, new OverviewPageRenderer(), output));
                        for (PackageTestResults packageResults : model.getPackages()) {
                            queue.add(generator(packageResults.getBaseUrl(), packageResults, new PackagePageRenderer(), output));
                            for (ClassTestResults classResults : packageResults.getClasses()) {
                                queue.add(generator(classResults.getBaseUrl(), classResults, new ClassPageRenderer(resultsProvider), output));
                            }
                        }
                    }
                });
            }
        }, reportDir);
    } catch (Exception e) {
        throw new GradleException(String.format("Could not generate test report to '%s'.", reportDir), e);
    }
}
Also used : Action(org.gradle.api.Action) BuildOperationQueue(org.gradle.internal.operations.BuildOperationQueue) IOException(java.io.IOException) IOException(java.io.IOException) GradleException(org.gradle.api.GradleException) HtmlReportBuilder(org.gradle.reporting.HtmlReportBuilder) GradleException(org.gradle.api.GradleException) HtmlReportRenderer(org.gradle.reporting.HtmlReportRenderer)

Example 2 with HtmlReportRenderer

use of org.gradle.reporting.HtmlReportRenderer in project gradle by gradle.

the class ProfileReportRenderer method writeTo.

public void writeTo(BuildProfile buildProfile, File file) {
    HtmlReportRenderer renderer = new HtmlReportRenderer();
    renderer.renderSinglePage(buildProfile, new ProfilePageRenderer(), file);
}
Also used : HtmlReportRenderer(org.gradle.reporting.HtmlReportRenderer)

Example 3 with HtmlReportRenderer

use of org.gradle.reporting.HtmlReportRenderer in project gradle by gradle.

the class DefaultTestReport method generateFiles.

private void generateFiles(AllTestResults model, final TestResultsProvider resultsProvider, final File reportDir) {
    try {
        HtmlReportRenderer htmlRenderer = new HtmlReportRenderer();
        buildOperationExecutor.run(new RunnableBuildOperation() {

            @Override
            public void run(BuildOperationContext context) {
                // Clean-up old HTML report directories
                GFileUtils.deleteQuietly(new File(reportDir, "packages"));
                GFileUtils.deleteQuietly(new File(reportDir, "classes"));
            }

            @Override
            public BuildOperationDescriptor.Builder description() {
                return BuildOperationDescriptor.displayName("Delete old HTML results");
            }
        });
        htmlRenderer.render(model, new ReportRenderer<AllTestResults, HtmlReportBuilder>() {

            @Override
            public void render(final AllTestResults model, final HtmlReportBuilder output) throws IOException {
                buildOperationExecutor.runAll(new Action<BuildOperationQueue<HtmlReportFileGenerator<? extends CompositeTestResults>>>() {

                    @Override
                    public void execute(BuildOperationQueue<HtmlReportFileGenerator<? extends CompositeTestResults>> queue) {
                        queue.add(generator("index.html", model, new OverviewPageRenderer(), output));
                        for (PackageTestResults packageResults : model.getPackages()) {
                            queue.add(generator(packageResults.getBaseUrl(), packageResults, new PackagePageRenderer(), output));
                            for (ClassTestResults classResults : packageResults.getClasses()) {
                                queue.add(generator(classResults.getBaseUrl(), classResults, new ClassPageRenderer(resultsProvider), output));
                            }
                        }
                    }
                });
            }
        }, reportDir);
    } catch (Exception e) {
        throw new GradleException(String.format("Could not generate test report to '%s'.", reportDir), e);
    }
}
Also used : BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) Action(org.gradle.api.Action) BuildOperationQueue(org.gradle.internal.operations.BuildOperationQueue) HtmlReportBuilder(org.gradle.reporting.HtmlReportBuilder) IOException(java.io.IOException) IOException(java.io.IOException) GradleException(org.gradle.api.GradleException) HtmlReportBuilder(org.gradle.reporting.HtmlReportBuilder) GradleException(org.gradle.api.GradleException) RunnableBuildOperation(org.gradle.internal.operations.RunnableBuildOperation) File(java.io.File) HtmlReportRenderer(org.gradle.reporting.HtmlReportRenderer)

Example 4 with HtmlReportRenderer

use of org.gradle.reporting.HtmlReportRenderer 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>() {

        @Override
        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) {
            generate(builder);
        }
    }, outputFile);
}
Also used : Report(org.gradle.api.reporting.Report) DirectoryReport(org.gradle.api.reporting.DirectoryReport) Collection(java.util.Collection) HtmlPageBuilder(org.gradle.reporting.HtmlPageBuilder) HtmlReportRenderer(org.gradle.reporting.HtmlReportRenderer) Writer(java.io.Writer) Comparator(java.util.Comparator)

Example 5 with HtmlReportRenderer

use of org.gradle.reporting.HtmlReportRenderer in project gradle by gradle.

the class HtmlDependencyReporter method render.

@Override
public void render(final Set<Project> projects, File outputDirectory) {
    this.outputDirectory = outputDirectory;
    HtmlReportRenderer renderer = new HtmlReportRenderer();
    renderer.render(projects, new ReportRenderer<Set<Project>, HtmlReportBuilder>() {

        @Override
        public void render(Set<Project> model, HtmlReportBuilder builder) {
            Transformer<String, Project> htmlPageScheme = projectNamingScheme("html");
            Transformer<String, Project> jsScheme = projectNamingScheme("js");
            ProjectPageRenderer projectPageRenderer = new ProjectPageRenderer(jsScheme);
            builder.renderRawHtmlPage("index.html", projects, new ProjectsPageRenderer(htmlPageScheme));
            for (Project project : projects) {
                String jsFileName = jsScheme.transform(project);
                generateJsFile(project, jsFileName);
                String htmlFileName = htmlPageScheme.transform(project);
                builder.renderRawHtmlPage(htmlFileName, project, projectPageRenderer);
            }
        }
    }, outputDirectory);
}
Also used : Project(org.gradle.api.Project) Set(java.util.Set) HtmlReportBuilder(org.gradle.reporting.HtmlReportBuilder) Transformer(org.gradle.api.Transformer) HtmlReportRenderer(org.gradle.reporting.HtmlReportRenderer)

Aggregations

HtmlReportRenderer (org.gradle.reporting.HtmlReportRenderer)5 HtmlReportBuilder (org.gradle.reporting.HtmlReportBuilder)3 IOException (java.io.IOException)2 Action (org.gradle.api.Action)2 GradleException (org.gradle.api.GradleException)2 BuildOperationQueue (org.gradle.internal.operations.BuildOperationQueue)2 File (java.io.File)1 Writer (java.io.Writer)1 Collection (java.util.Collection)1 Comparator (java.util.Comparator)1 Set (java.util.Set)1 Project (org.gradle.api.Project)1 Transformer (org.gradle.api.Transformer)1 DirectoryReport (org.gradle.api.reporting.DirectoryReport)1 Report (org.gradle.api.reporting.Report)1 BuildOperationContext (org.gradle.internal.operations.BuildOperationContext)1 RunnableBuildOperation (org.gradle.internal.operations.RunnableBuildOperation)1 HtmlPageBuilder (org.gradle.reporting.HtmlPageBuilder)1