org.gradle.api.reporting.DirectoryReport Java Examples

The following examples show how to use org.gradle.api.reporting.DirectoryReport. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Test.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void handleTestFailures() {
    String message = "There were failing tests";

    DirectoryReport htmlReport = reports.getHtml();
    if (htmlReport.isEnabled()) {
        String reportUrl = new ConsoleRenderer().asClickableFileUrl(htmlReport.getEntryPoint());
        message = message.concat(". See the report at: " + reportUrl);
    } else {
        DirectoryReport junitXmlReport = reports.getJunitXml();
        if (junitXmlReport.isEnabled()) {
            String resultsUrl = new ConsoleRenderer().asClickableFileUrl(junitXmlReport.getEntryPoint());
            message = message.concat(". See the results at: " + resultsUrl);
        }
    }

    if (getIgnoreFailures()) {
        getLogger().warn(message);
    } else {
        throw new GradleException(message);
    }
}
 
Example #2
Source File: Test.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void handleTestFailures() {
    String message = "There were failing tests";

    DirectoryReport htmlReport = reports.getHtml();
    if (htmlReport.isEnabled()) {
        String reportUrl = new ConsoleRenderer().asClickableFileUrl(htmlReport.getEntryPoint());
        message = message.concat(". See the report at: " + reportUrl);
    } else {
        DirectoryReport junitXmlReport = reports.getJunitXml();
        if (junitXmlReport.isEnabled()) {
            String resultsUrl = new ConsoleRenderer().asClickableFileUrl(junitXmlReport.getEntryPoint());
            message = message.concat(". See the results at: " + resultsUrl);
        }
    }

    if (getIgnoreFailures()) {
        getLogger().warn(message);
    } else {
        throw new GradleException(message);
    }
}
 
Example #3
Source File: Test.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void handleTestFailures() {
    String message = "There were failing tests";

    DirectoryReport htmlReport = reports.getHtml();
    if (htmlReport.isEnabled()) {
        String reportUrl = new ConsoleRenderer().asClickableFileUrl(htmlReport.getEntryPoint());
        message = message.concat(". See the report at: " + reportUrl);
    } else {
        DirectoryReport junitXmlReport = reports.getJunitXml();
        if (junitXmlReport.isEnabled()) {
            String resultsUrl = new ConsoleRenderer().asClickableFileUrl(junitXmlReport.getEntryPoint());
            message = message.concat(". See the results at: " + resultsUrl);
        }
    }

    if (getIgnoreFailures()) {
        getLogger().warn(message);
    } else {
        throw new GradleException(message);
    }
}
 
Example #4
Source File: Test.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void handleTestFailures() {
    String message = "There were failing tests";

    DirectoryReport htmlReport = reports.getHtml();
    if (htmlReport.isEnabled()) {
        String reportUrl = new ConsoleRenderer().asClickableFileUrl(htmlReport.getEntryPoint());
        message = message.concat(". See the report at: " + reportUrl);
    } else {
        DirectoryReport junitXmlReport = reports.getJunitXml();
        if (junitXmlReport.isEnabled()) {
            String resultsUrl = new ConsoleRenderer().asClickableFileUrl(junitXmlReport.getEntryPoint());
            message = message.concat(". See the results at: " + resultsUrl);
        }
    }

    if (getIgnoreFailures()) {
        getLogger().warn(message);
    } else {
        throw new GradleException(message);
    }
}
 
Example #5
Source File: TestNGTestFramework.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static void conventionMapOutputDirectory(TestNGOptions options, final DirectoryReport html) {
    new DslObject(options).getConventionMapping().map("outputDirectory", new Callable<File>() {
        public File call() {
            return html.getDestination();
        }
    });
}
 
Example #6
Source File: TestNGTestFramework.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static void conventionMapOutputDirectory(TestNGOptions options, final DirectoryReport html) {
    new DslObject(options).getConventionMapping().map("outputDirectory", new Callable<File>() {
        public File call() {
            return html.getDestination();
        }
    });
}
 
Example #7
Source File: BuildDashboardPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ReportingBasePlugin.class);

    final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);

    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);
    }
}
 
Example #8
Source File: BuildDashboardGenerator.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private File getHtmlLinkedFileFromReport(Report report) {
    if(report instanceof DirectoryReport){
        return ((DirectoryReport) report).getEntryPoint();
    } else{
        return report.getDestination();
    }
}
 
Example #9
Source File: TestNGTestFramework.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static void conventionMapOutputDirectory(TestNGOptions options, final DirectoryReport html) {
    new DslObject(options).getConventionMapping().map("outputDirectory", new Callable<File>() {
        public File call() {
            return html.getDestination();
        }
    });
}
 
Example #10
Source File: BuildDashboardGenerator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private File getHtmlLinkedFileFromReport(Report report) {
    if(report instanceof DirectoryReport){
        return ((DirectoryReport) report).getEntryPoint();
    } else{
        return report.getDestination();
    }
}
 
Example #11
Source File: BuildDashboardPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ReportingBasePlugin.class);

    final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);

    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);
    }
}
 
Example #12
Source File: BuildDashboardPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().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);
    }
}
 
Example #13
Source File: TestNGTestFramework.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static void conventionMapOutputDirectory(TestNGOptions options, final DirectoryReport html) {
    new DslObject(options).getConventionMapping().map("outputDirectory", new Callable<File>() {
        public File call() {
            return html.getDestination();
        }
    });
}
 
Example #14
Source File: BuildDashboardPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().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);
    }
}
 
Example #15
Source File: BuildDashboardGenerator.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private File getHtmlLinkedFileFromReport(Report report) {
    if (report instanceof DirectoryReport) {
        return ((DirectoryReport) report).getEntryPoint();
    } else {
        return report.getDestination();
    }
}
 
Example #16
Source File: BuildDashboardGenerator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private File getHtmlLinkedFileFromReport(Report report) {
    if (report instanceof DirectoryReport) {
        return ((DirectoryReport) report).getEntryPoint();
    } else {
        return report.getDestination();
    }
}
 
Example #17
Source File: DefaultBuildDashboardReports.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DirectoryReport getHtml() {
    return (DirectoryReport)getByName("html");
}
 
Example #18
Source File: DefaultDependencyReportContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DirectoryReport getHtml() {
    return (DirectoryReport) getByName("html");
}
 
Example #19
Source File: JacocoReportsContainerImpl.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DirectoryReport getHtml() {
    return (DirectoryReport)getByName("html");
}
 
Example #20
Source File: Test.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@TaskAction
public void executeTests() {
    LogLevel currentLevel = getCurrentLogLevel();
    TestLogging levelLogging = testLogging.get(currentLevel);
    TestExceptionFormatter exceptionFormatter = getExceptionFormatter(levelLogging);
    TestEventLogger eventLogger = new TestEventLogger(getTextOutputFactory(), currentLevel, levelLogging, exceptionFormatter);
    addTestListener(eventLogger);
    addTestOutputListener(eventLogger);
    if (!getFilter().getIncludePatterns().isEmpty()) {
        addTestListener(new NoMatchingTestsReporter("No tests found for given includes: " + getFilter().getIncludePatterns()));
    }

    File binaryResultsDir = getBinResultsDir();
    getProject().delete(binaryResultsDir);
    getProject().mkdir(binaryResultsDir);

    Map<String, TestClassResult> results = new HashMap<String, TestClassResult>();
    TestOutputStore testOutputStore = new TestOutputStore(binaryResultsDir);

    TestOutputStore.Writer outputWriter = testOutputStore.writer();
    TestReportDataCollector testReportDataCollector = new TestReportDataCollector(results, outputWriter);

    addTestListener(testReportDataCollector);
    addTestOutputListener(testReportDataCollector);

    TestCountLogger testCountLogger = new TestCountLogger(getProgressLoggerFactory());
    addTestListener(testCountLogger);

    TestResultProcessor resultProcessor = new TestListenerAdapter(
            getTestListenerBroadcaster().getSource(), testOutputListenerBroadcaster.getSource());

    if (testExecuter == null) {
        testExecuter = new DefaultTestExecuter(getProcessBuilderFactory(), getActorFactory());
    }

    try {
        testExecuter.execute(this, resultProcessor);
    } finally {
        testExecuter = null;
        testListenerBroadcaster.removeAll();
        testOutputListenerBroadcaster.removeAll();
        outputWriter.close();
    }

    new TestResultSerializer(binaryResultsDir).write(results.values());

    TestResultsProvider testResultsProvider = new InMemoryTestResultsProvider(results.values(), testOutputStore.reader());

    try {
        if (testReporter == null) {
            testReporter = new DefaultTestReport();
        }

        JUnitXmlReport junitXml = reports.getJunitXml();
        if (junitXml.isEnabled()) {
            TestOutputAssociation outputAssociation = junitXml.isOutputPerTestCase()
                    ? TestOutputAssociation.WITH_TESTCASE
                    : TestOutputAssociation.WITH_SUITE;
            Binary2JUnitXmlReportGenerator binary2JUnitXmlReportGenerator = new Binary2JUnitXmlReportGenerator(junitXml.getDestination(), testResultsProvider, outputAssociation);
            binary2JUnitXmlReportGenerator.generate();
        }

        DirectoryReport html = reports.getHtml();
        if (!html.isEnabled()) {
            getLogger().info("Test report disabled, omitting generation of the HTML test report.");
        } else {
            testReporter.generateReport(testResultsProvider, html.getDestination());
        }
    } finally {
        CompositeStoppable.stoppable(testResultsProvider).stop();
        testReporter = null;
        testFramework = null;
    }

    if (testCountLogger.hadFailures()) {
        handleTestFailures();
    }
}
 
Example #21
Source File: DefaultTestTaskReports.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DirectoryReport getHtml() {
    return (DirectoryReport) getByName("html");
}
 
Example #22
Source File: DefaultBuildDashboardReports.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultBuildDashboardReports(Task task) {
    super(DirectoryReport.class, task);
    add(TaskGeneratedSingleDirectoryReport.class, "html", task, "index.html");
}
 
Example #23
Source File: ReportUploader.java    From nomulus with Apache License 2.0 4 votes vote down vote up
/**
 * Converts a Gradle Task into a TaskData.
 *
 * @param rootDir the root directory of the main Project - used to get the relative path of any
 *     Task files.
 */
private TaskData createTaskData(Task task, Path rootDir) {
  TaskData.State state =
      task.getState().getFailure() != null
          ? TaskData.State.FAILURE
          : task.getState().getUpToDate() ? TaskData.State.UP_TO_DATE : TaskData.State.SUCCESS;
  String log = logs.get(task.getPath()).toString();

  TaskData.Builder builder =
      TaskData.builder()
          .setState(state)
          .setUniqueName(task.getPath())
          .setDescription(
              Optional.ofNullable(task.getDescription()).orElse("[No description available]"));
  if (!log.isEmpty()) {
    builder.setLog(toByteArraySupplier(log));
  }

  Reporting<? extends ReportContainer<? extends Report>> reporting = asReporting(task);

  if (reporting != null) {
    // This Task is also a Reporting task! It has a destination file/directory for every supported
    // format.
    // Add the files for each of the formats into the ReportData.
    reporting
        .getReports()
        .getAsMap()
        .forEach(
            (type, report) -> {
              File destination = report.getDestination();
              // The destination could be a file, or a directory. If it's a directory - the Report
              // could have created multiple files - and we need to know to which one of those to
              // link.
              //
              // If we're lucky, whoever implemented the Report made sure to extend
              // DirectoryReport, which gives us the entry point to all the files.
              //
              // This isn't guaranteed though, as it depends on the implementer.
              Optional<File> entryPointHint =
                  destination.isDirectory() && (report instanceof DirectoryReport)
                      ? Optional.ofNullable(((DirectoryReport) report).getEntryPoint())
                      : Optional.empty();
              builder
                  .reportsBuilder()
                  .put(type, readFilesWithEntryPoint(destination, entryPointHint, rootDir));
            });
  }
  return builder.build();
}
 
Example #24
Source File: JacocoReportsContainerImpl.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DirectoryReport getHtml() {
    return (DirectoryReport)getByName("html");
}
 
Example #25
Source File: DefaultDependencyReportContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DirectoryReport getHtml() {
    return (DirectoryReport) getByName("html");
}
 
Example #26
Source File: Test.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@TaskAction
public void executeTests() {
    LogLevel currentLevel = getCurrentLogLevel();
    TestLogging levelLogging = testLogging.get(currentLevel);
    TestExceptionFormatter exceptionFormatter = getExceptionFormatter(levelLogging);
    TestEventLogger eventLogger = new TestEventLogger(textOutputFactory, currentLevel, levelLogging, exceptionFormatter);
    addTestListener(eventLogger);
    addTestOutputListener(eventLogger);
    if (!getFilter().getIncludePatterns().isEmpty()) {
        addTestListener(new NoMatchingTestsReporter("No tests found for given includes: " + getFilter().getIncludePatterns()));
    }

    File binaryResultsDir = getBinResultsDir();
    getProject().delete(binaryResultsDir);
    getProject().mkdir(binaryResultsDir);

    Map<String, TestClassResult> results = new HashMap<String, TestClassResult>();
    TestOutputStore testOutputStore = new TestOutputStore(binaryResultsDir);

    TestOutputStore.Writer outputWriter = testOutputStore.writer();
    TestReportDataCollector testReportDataCollector = new TestReportDataCollector(results, outputWriter);

    addTestListener(testReportDataCollector);
    addTestOutputListener(testReportDataCollector);

    TestCountLogger testCountLogger = new TestCountLogger(progressLoggerFactory);
    addTestListener(testCountLogger);

    TestResultProcessor resultProcessor = new TestListenerAdapter(
            getTestListenerBroadcaster().getSource(), testOutputListenerBroadcaster.getSource());

    try {
        testExecuter.execute(this, resultProcessor);
    } finally {
        testListenerBroadcaster.removeAll();
        testOutputListenerBroadcaster.removeAll();
        outputWriter.close();
    }

    new TestResultSerializer(binaryResultsDir).write(results.values());

    TestResultsProvider testResultsProvider = new InMemoryTestResultsProvider(results.values(), testOutputStore.reader());

    try {
        JUnitXmlReport junitXml = reports.getJunitXml();
        if (junitXml.isEnabled()) {
            TestOutputAssociation outputAssociation = junitXml.isOutputPerTestCase()
                    ? TestOutputAssociation.WITH_TESTCASE
                    : TestOutputAssociation.WITH_SUITE;
            Binary2JUnitXmlReportGenerator binary2JUnitXmlReportGenerator = new Binary2JUnitXmlReportGenerator(junitXml.getDestination(), testResultsProvider, outputAssociation);
            binary2JUnitXmlReportGenerator.generate();
        }

        DirectoryReport html = reports.getHtml();
        if (!html.isEnabled()) {
            getLogger().info("Test report disabled, omitting generation of the HTML test report.");
        } else {
            testReporter.generateReport(testResultsProvider, html.getDestination());
        }
    } finally {
        CompositeStoppable.stoppable(testResultsProvider).stop();
    }

    testFramework = null;

    if (testCountLogger.hadFailures()) {
        handleTestFailures();
    }
}
 
Example #27
Source File: DefaultTestTaskReports.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DirectoryReport getHtml() {
    return (DirectoryReport) getByName("html");
}
 
Example #28
Source File: DefaultBuildDashboardReports.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DirectoryReport getHtml() {
    return (DirectoryReport)getByName("html");
}
 
Example #29
Source File: DefaultBuildDashboardReports.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DirectoryReport getHtml() {
    return (DirectoryReport)getByName("html");
}
 
Example #30
Source File: JacocoReportsContainerImpl.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DirectoryReport getHtml() {
    return (DirectoryReport)getByName("html");
}