use of org.gradle.api.plugins.jvm.JvmTestSuiteTarget in project gradle by gradle.
the class JacocoPlugin method createCoverageDataVariant.
private void createCoverageDataVariant(Project project, JvmTestSuite suite, JvmTestSuiteTarget target) {
final Configuration variant = project.getConfigurations().create(COVERAGE_DATA_ELEMENTS_VARIANT_PREFIX + StringUtils.capitalize(target.getName()));
variant.setDescription("Binary data file containing results of Jacoco test coverage reporting for the " + suite.getName() + " Test Suite's " + target.getName() + " target.");
variant.setVisible(false);
variant.setCanBeResolved(false);
variant.setCanBeConsumed(true);
variant.extendsFrom(project.getConfigurations().getByName(suite.getSources().getImplementationConfigurationName()), project.getConfigurations().getByName(suite.getSources().getRuntimeOnlyConfigurationName()));
final ObjectFactory objects = project.getObjects();
variant.attributes(attributes -> {
attributes.attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.class, Category.VERIFICATION));
attributes.attribute(TestSuiteName.TEST_SUITE_NAME_ATTRIBUTE, objects.named(TestSuiteName.class, suite.getName()));
attributes.attribute(TestSuiteTargetName.TEST_SUITE_TARGET_NAME_ATTRIBUTE, objects.named(TestSuiteTargetName.class, target.getName()));
attributes.attributeProvider(TestSuiteType.TEST_SUITE_TYPE_ATTRIBUTE, suite.getTestType().map(tt -> objects.named(TestSuiteType.class, tt)));
attributes.attribute(VerificationType.VERIFICATION_TYPE_ATTRIBUTE, objects.named(VerificationType.class, VerificationType.JACOCO_RESULTS));
});
variant.getOutgoing().artifact(target.getTestTask().map(task -> task.getExtensions().getByType(JacocoTaskExtension.class).getDestinationFile()), artifact -> {
artifact.setType(ArtifactTypeDefinition.BINARY_DATA_TYPE);
artifact.builtBy(target.getTestTask());
});
}
Aggregations