org.gradle.testing.jacoco.plugins.JacocoPlugin Java Examples

The following examples show how to use org.gradle.testing.jacoco.plugins.JacocoPlugin. 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: TransportPlugin.java    From transport with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(Project project) {

    TransportPluginConfig extension = project.getExtensions().create("transport", TransportPluginConfig.class, project);

    project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> {
      project.getPlugins().apply(ScalaPlugin.class);
      project.getPlugins().apply(DistributionPlugin.class);
      project.getConfigurations().create(ShadowBasePlugin.getCONFIGURATION_NAME());

      JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
      SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(extension.mainSourceSetName);
      SourceSet testSourceSet = javaConvention.getSourceSets().getByName(extension.testSourceSetName);

      configureBaseSourceSets(project, mainSourceSet, testSourceSet);
      Defaults.DEFAULT_PLATFORMS.forEach(
          platform -> configurePlatform(project, platform, mainSourceSet, testSourceSet, extension.outputDirFile));
    });
    // Disable Jacoco for platform test tasks as it is known to cause issues with Presto and Hive tests
    project.getPlugins().withType(JacocoPlugin.class, (jacocoPlugin) -> {
        Defaults.DEFAULT_PLATFORMS.forEach(platform -> {
          project.getTasksByName(testTaskName(platform), true).forEach(task -> {
            JacocoTaskExtension jacocoExtension = task.getExtensions().findByType(JacocoTaskExtension.class);
            if (jacocoExtension != null) {
              jacocoExtension.setEnabled(false);
            }
          });
        });
    });
  }
 
Example #2
Source File: AggregateJacocoReportPlugin.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public void apply(Project project) {
    project.getPlugins().apply(JacocoPlugin.class);

    project.getTasks().register("aggregateJacocoReport", JacocoReport.class, reportTask -> {

        reportTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
        reportTask.setDescription(String.format("Generates aggregated code coverage report for the %s project.", project.getPath()));

        project.allprojects(subproject -> {
            subproject.getPlugins().withType(JavaPlugin.class, javaPlugin -> {
                SourceSetContainer sourceSets = subproject.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
                SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
                reportTask.sourceSets(main);
            });

            subproject.getTasks()
                    .withType(Test.class)
                    .forEach(reportTask::executionData);
        });

        JacocoPluginExtension reportingExtension = project.getExtensions().getByType(JacocoPluginExtension.class);
        reportTask.getReports().getHtml().setEnabled(true);
        reportTask.getReports().all(report -> {
            if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) {
                report.setDestination(project.provider(() -> new File(reportingExtension.getReportsDir(), reportTask.getName() + "/" + report.getName())));
            }
            else {
                report.setDestination(project.provider(() -> new File(reportingExtension.getReportsDir(), reportTask.getName() + "/" + reportTask.getName() + "." + report.getName())));
            }
        });
    });


}
 
Example #3
Source File: AggregateJacocoReportPlugin.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public void apply(Project project) {
    project.getPlugins().apply(JacocoPlugin.class);

    project.getTasks().register("aggregateJacocoReport", JacocoReport.class, reportTask -> {

        reportTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
        reportTask.setDescription(String.format("Generates aggregated code coverage report for the %s project.", project.getPath()));

        project.allprojects(subproject -> {
            subproject.getPlugins().withType(JavaPlugin.class, javaPlugin -> {
                SourceSetContainer sourceSets = subproject.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
                SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
                reportTask.sourceSets(main);
            });

            subproject.getTasks()
                    .withType(Test.class)
                    .forEach(reportTask::executionData);
        });

        JacocoPluginExtension reportingExtension = project.getExtensions().getByType(JacocoPluginExtension.class);
        reportTask.getReports().getHtml().setEnabled(true);
        reportTask.getReports().all(report -> {
            if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) {
                report.setDestination(project.provider(() -> new File(reportingExtension.getReportsDir(), reportTask.getName() + "/" + report.getName())));
            }
            else {
                report.setDestination(project.provider(() -> new File(reportingExtension.getReportsDir(), reportTask.getName() + "/" + reportTask.getName() + "." + report.getName())));
            }
        });
    });


}