Search in sources :

Example 1 with GenerateBuildDashboard

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

the class BuildDashboardPlugin method apply.

public void apply(final Project project) {
    project.getPluginManager().apply(ReportingBasePlugin.class);
    final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);
    buildDashboardTask.setDescription("Generates a dashboard of all the reports produced by this build.");
    buildDashboardTask.setGroup("reporting");
    DirectoryReport htmlReport = buildDashboardTask.getReports().getHtml();
    ConventionMapping htmlReportConventionMapping = new DslObject(htmlReport).getConventionMapping();
    htmlReportConventionMapping.map("destination", new Callable<Object>() {

        public Object call() throws Exception {
            return project.getExtensions().getByType(ReportingExtension.class).file("buildDashboard");
        }
    });
    Action<Task> captureReportingTasks = new Action<Task>() {

        public void execute(Task task) {
            if (!(task instanceof Reporting)) {
                return;
            }
            Reporting reporting = (Reporting) task;
            buildDashboardTask.aggregate(reporting);
            if (!task.equals(buildDashboardTask)) {
                task.finalizedBy(buildDashboardTask);
            }
        }
    };
    for (Project aProject : project.getAllprojects()) {
        aProject.getTasks().all(captureReportingTasks);
    }
}
Also used : DslObject(org.gradle.api.internal.plugins.DslObject) DslObject(org.gradle.api.internal.plugins.DslObject) Reporting(org.gradle.api.reporting.Reporting) DirectoryReport(org.gradle.api.reporting.DirectoryReport) ConventionMapping(org.gradle.api.internal.ConventionMapping) GenerateBuildDashboard(org.gradle.api.reporting.GenerateBuildDashboard)

Aggregations

ConventionMapping (org.gradle.api.internal.ConventionMapping)1 DslObject (org.gradle.api.internal.plugins.DslObject)1 DirectoryReport (org.gradle.api.reporting.DirectoryReport)1 GenerateBuildDashboard (org.gradle.api.reporting.GenerateBuildDashboard)1 Reporting (org.gradle.api.reporting.Reporting)1