use of org.gradle.api.reporting.ConfigurableReport 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"));
reportTask.getReports().all(new Action<ConfigurableReport>() {
@Override
public void execute(final ConfigurableReport report) {
if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) {
report.setDestination(project.provider(new Callable<File>() {
@Override
public File call() throws Exception {
return new File(extension.getReportsDir(), task.getName() + "/" + report.getName());
}
}));
} else {
report.setDestination(project.provider(new Callable<File>() {
@Override
public File call() throws Exception {
return new File(extension.getReportsDir(), task.getName() + "/" + reportTask.getName() + "." + report.getName());
}
}));
}
}
});
}
Aggregations