Caleb Cushing
10/02/2024, 6:53 PMJavaBasePlugin for this to work properly? I'm just thinking about it, and doubting that I should have added it, but then maybe a project couldn't work without it... esp if CHECK and Test come from it.
public class CoveragePlugin implements Plugin<Project> {
@Override
public void apply(@NonNull Project project) {
project.getPlugins().apply(JavaBasePlugin.class);
project.getPlugins().apply(JacocoPlugin.class);
var coverage = project.getExtensions().create("coverage", CoveragePluginExtension.class);
var tasks = project.getTasks();
tasks
.withType(JacocoReport.class)
.configureEach(jacocoReport -> {
var tests = tasks.withType(Test.class);
jacocoReport.dependsOn(tests);
tests.forEach(jacocoReport::executionData);
});
tasks.named(JavaBasePlugin.CHECK_TASK_NAME, task -> task.dependsOn(tasks.withType(JacocoReport.class)));
tasks
.withType(JacocoCoverageVerification.class)
.configureEach(verification -> {
verification.dependsOn(tasks.withType(JacocoReport.class));
// execution data needs to be aggregated from all exec files in the project for multi jvm test suite testing
verification.executionData(tasks.withType(JacocoReport.class).stream().map(JacocoReport::getExecutionData));
verification.violationRules(rules -> {
rules.rule(r -> {
r.limit(limit -> limit.setMinimum(coverage.getMinimum().orElse(0.9).map(BigDecimal::valueOf).get()));
});
});
});
}
}Vampire
10/02/2024, 7:58 PMTest is a built-in type, so it is always available. And check is not coming from java-base, but lifecycle-base.