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();
}
};
}
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());
}
});
}
}
});
}
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);
}
Aggregations