@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); }
private void configureJacocoReportDefaults(final JacocoPluginExtension extension, final JacocoReport reportTask) { reportTask.getReports().all(new Action<Report>() { @Override public void execute(final Report report) { ConventionMapping mapping = ((IConventionAware) report).getConventionMapping(); mapping.map("enabled", Callables.returning(report.getName().equals("html"))); if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) { mapping.map("destination", new Callable<File>() { @Override public File call() { return new File(extension.getReportsDir(), reportTask.getName() + "/" + report.getName()); } }); } else { mapping.map("destination", new Callable<File>() { @Override public File call() { return new File(extension.getReportsDir(), reportTask.getName() + "/" + reportTask.getName() + "." + report.getName()); } }); } } }); }
private void configureDefaultReportTask( final Test test, JGivenReportTask reportTask, final ReportingExtension reportingExtension ) { ConventionMapping mapping = ( (IConventionAware) reportTask ).getConventionMapping(); mapping.map( "results", new Callable<File>() { @Override public File call() { return test.getExtensions().getByType( JGivenTaskExtension.class ).getResultsDir(); } } ); mapping.getConventionValue( reportTask.getReports(), "reports", false ).all( new Action<Report>() { @Override public void execute( final Report report ) { ConventionMapping reportMapping = ( (IConventionAware) report ).getConventionMapping(); reportMapping.map( "destination", new Callable<File>() { @Override public File call() { return reportingExtension.file( "jgiven" + "/" + test.getName() + "/" + report.getName() ); } } ); } } ); }
public DefaultReportContainer(Class<? extends T> type, Instantiator instantiator) { super(type, instantiator, Report.NAMER); enabled = matching(new Spec<T>() { public boolean isSatisfiedBy(T element) { return element.isEnabled(); } }); beforeChange(new Runnable() { public void run() { throw new ImmutableViolationException(); } }); }
private File getHtmlLinkedFileFromReport(Report report) { if (report instanceof DirectoryReport) { return ((DirectoryReport) report).getEntryPoint(); } else { return report.getDestination(); } }
private void addDefaultReportTask(final JacocoPluginExtension extension, final Test task) { final JacocoReport reportTask = project.getTasks().create("jacoco" + StringUtils.capitalise(task.getName()) + "Report", JacocoReport.class); 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()); } }); } } }); }
@Input public SortedSet<String> getEnabledReportNames() { return CollectionUtils.collect(getEnabled(), new TreeSet<String>(), new Transformer<String, Report>() { public String transform(Report report) { return report.getName(); } }); }
public BuildDashboardGenerator(Set<Report> reports, 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; }
private void generate(Writer writer) { new Html(writer) {{ html(); head(); meta().httpEquiv("Content-Type").content("text/html; charset=utf-8"); link().rel("stylesheet").type("text/css").href("base-style.css").end(); link().rel("stylesheet").type("text/css").href("style.css").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(); } end(); div().id("footer").text(String.format("Generated by %s", GradleVersion.current())); endAll(); }}; }
private File getHtmlLinkedFileFromReport(Report report) { if(report instanceof DirectoryReport){ return ((DirectoryReport) report).getEntryPoint(); } else{ return report.getDestination(); } }
private void configureJGivenReportDefaults( Project project ) { project.getTasks().withType( JGivenReportTask.class, new Action<JGivenReportTask>() { @Override public void execute( JGivenReportTask reportTask ) { reportTask.getReports().all( new Action<Report>() { @Override public void execute( final Report report ) { ConventionMapping mapping = ( (IConventionAware) report ).getConventionMapping(); mapping.map( "enabled", Callables.returning( report.getName().equals( JGivenHtmlReportImpl.NAME ) ) ); } } ); } } ); }
@Override public String apply(Report report) { return report.getName(); }
@Override public File apply(Report report) { return report.getDestination(); }
@Override public boolean apply(Report report) { return report.getOutputType() == Report.OutputType.DIRECTORY; }
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(); }}; }
public DefaultDependencyReportContainer(Task task) { super(Report.class, task); add(TaskGeneratedSingleDirectoryReport.class, "html", task, "index.html"); }
public File transform(Report original) { return original.getDestination(); }
public boolean isSatisfiedBy(Report report) { return report.getOutputType() == Report.OutputType.DIRECTORY; }
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(String.format(" at %s", builder.formatDate(new Date()))); end(); end(); end(); endAll(); }}; }